我想在点击listview
项目
listView.setOnItemClickListener(new ItemClickEvent());
这是类 ItemClickEvent
class ItemClickEvent implements AdapterView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
if (mBluetoothAdapter.getState() != BluetoothAdapter.STATE_ON) {
Toast.makeText(MainActivity.this, "Bluetooth not enable",
Toast.LENGTH_SHORT).show();
return;
}
if (mBluetoothAdapter.isDiscovering())
mBluetoothAdapter.cancelDiscovery();
Intent i = new Intent(MainActivity.this, DetailItemActivity.class);
startActivity(i);
}
这是类 DetailItemActivity :
public class DetailItemActivity extends Activity {
TextView tv1, tv2,tv3,tv4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.abcd);
}
}
我创建了abcd.xml
但是当我点击listview
项时,它无法正常工作。
答案 0 :(得分:0)
只需在DetailItemActivity类中添加接收Intent: -
Intent intent = getIntent();