我是Android Studio的新手。我正在尝试使用搜寻栏更改列表视图中项目的值。当我尝试在其中编写代码时,出现“无法重新构建构造器”错误
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
我下面的完整代码。
package com.tshum.timestable;
import android.support.annotation.IntDef;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SeekBar;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final SeekBar timesControl = (SeekBar) findViewById(R.id.seekBar);
timesControl.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
final ListView TimesView = (ListView)findViewById(R.id.TimesView);
final ArrayList <Integer> numbers = new ArrayList<Integer>();
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
ArrayAdapter<Integer> arrayAdapter = new ArrayAdapter<Integer>(this, android.R.layout.simple_expandable_list_item_1, numbers);
TimesView.setAdapter(arrayAdapter);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
当我尝试在OnProgressChanged方法中创建ArrayAdapter对象时,发生回溯
ArrayAdapter<Integer> arrayAdapter = new ArrayAdapter<Integer>(this, android.R.layout.simple_expandable_list_item_1, numbers);
如何解决此追溯?
尝试,但下面的方法失败
(getActivity(), R.layout.simplerow, planetList);
和
(activityName.this, R.layout.simplerow, planetList);