简体   繁体   中英

VariableDeclaratorId and misplaced construct error. Android

Below, setting text and setting progress gives me the error.. Multiple markers at this line - Syntax error on token(s), misplaced construct(s) - Syntax error on token "myLabel", VariableDeclaratorId expected after this token

Is this because they depend on the context and string coming from the constructor? These errors are way too vague.

Thanks for your help.

public class CustomSeekBar implements SeekBar.OnSeekBarChangeListener {

Context myContext;
CharSequence myLabel;

CustomSeekBar(Context context, CharSequence label){
    myContext = context;
    myLabel = label;
}

TextView myValue = new TextView(myContext);
SeekBar mySeekBar = new SeekBar(myContext);
myValue.setText(myLabel);
mySeekBar.setProgress(3);

//mySeekBar.setOnSeekBarChangeListener();


 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {

 }
 public void onStopTrackingTouch(SeekBar seekBar){

 }
 public void onStartTrackingTouch (SeekBar seekBar){
 }


}

Did you want that code within your constructor?

CustomSeekBar(Context context, CharSequence label){
    myContext = context;
    myLabel = label;

    TextView myValue = new TextView(myContext);
    SeekBar mySeekBar = new SeekBar(myContext);
    myValue.setText(myLabel);
    mySeekBar.setProgress(3);

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM