【发布时间】:2011-07-10 13:28:41
【问题描述】:
我想创建一个列表视图,其中填充了我通过捆绑转移到此活动的项目。我对此完全陌生,所以我不知道如何。这是我到目前为止的位置:
public class Viewer extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
Bundle b = getIntent().getExtras();
final String name = b.getString("name");
Bundle a = getIntent().getExtras();
final String number = a.getString("number");
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, DETAILS));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();
}
});
}
static final String[] DETAILS = new String[] {
name, number
};
}
我想让字符串“name”和“number”出现在列表中,但是当我将它们放在
时出现错误“无法解析为变量” static final String[] DETAILS = new String[] {
name, number
};
}
【问题讨论】:
标签: android arrays listview bundle