0

如何在布局中设置一个可绘制对象以使用列表视图?这是我的代码和功能,但我无法点击项目:

public class ListMobileActivity extends Activity {

static final String[] Ristoranti = new String[] { "Osteria Mingot", "Cecchini", "Barrique", "Mediterraneo"};

ListView listView1;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list);

    ListView listView1 = (ListView) findViewById(R.id.listView);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_mobile, R.id.label, Ristoranti);

    listView1.setAdapter(adapter);


}
4

1 回答 1

0

如果我扩展 Activity 我可以设置我的可绘制对象,如果我扩展 ListActivity 我可以单击项目但可绘制对象出现在每个项目中

protected void onItemClick(ListView l, View v, int position, long id)  {

    //get selected items
//  String selectedValue = (String) getListAdapter().getItem(position);
    //Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();

}
于 2012-10-23T16:26:12.173 回答