大家好:我希望有人可以在这里帮助我,由查询生成的光标填充ListView
由 simple_list_item_2 定义的布局。要创建意图,我需要单击视图的第一个字符串,但在 String to Go 中我有类似
android.widget.TextView@411fbfb8
现在是代码。我不明白错误在哪里。
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, columns, ids, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
final ListView myList=(ListView)findViewById(R.id.listView1);
myList.setAdapter(adapter);
myList.setClickable(true);
/*
* Click Listener
*/
myList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> l, View v, int position, long id)
{
Log.v("io", "start");
Intent intent = new Intent(MainActivity.this, WorkActivity.class);
View buff = myList.getChildAt(position);
String toGo = buff.findViewById(android.R.id.text1).toString();
Log.v("io",toGo);
intent.putExtra("dname", toGo);
startActivity(intent);
}
} );