嘿,MainActivity中onPostExecute(string result)方法爆出了一个错误:"The method setListAdapter(CustomAdapter) is undefined for the type MainActivity.getTweets"MainActivity.javapublic class Main Activity extends Activity {
ArrayList<TweetDetailClass> tweets = new ArrayList<TweetDetailClass>();
protected void onCreate(Bundle savedInstanceState) { .. }
public boolean onCreateOptionsMenu(Menu menu) { .. }
public void searchTwitter(View view){
...
new GetTweets().execute(searchURL);
}
public class GetTweets extends AsyncTask<String, Void, String>{
protected String doInBackground(String... twitterURL){ .. }
protected void onPostExecute(String result) {
setListAdapter(new CustomAdapter(MainActivity.this, R.layout.listview, tweets));
}
}
}CustomAdapter Constructor 中的代码如下:CustomAdapter(Context c, int textView, ArrayList<TweetDetailClass> data){
//_data = data;
//_c = c;
super(c, textView, data);
this._data = data;
}
1 回答

喵喵时光机
TA贡献1846条经验 获得超7个赞
setListAdapter()
只有在Activity 继承ListActivity时才能用。你的xml布局文件肯定包含ListView 对象,id是 "@android:id/list"
。
如果满足继承条件的话,可以这样
yourListView.setAdapter(new CustomAdapter(MainActivity.this, R.layout.listview, tweets));
添加回答
举报
0/150
提交
取消