【发布时间】:2016-03-25 18:10:17
【问题描述】:
我创建了一个可以显示项目和子项目列表的 ListView,遵循这个问题:android-listview-subitems。
但是,当我单击其中一行时,出现错误:E/MessageQueue-JNI: java.lang.ClassCastException: android.widget.TwoLineListItem cannot be cast to android.widget.TextView
只有在我向 ListView 中的每个项目添加子项目后,该错误才开始发生。
listView 的监听器发生错误,代码如下:
//listview listener
lvAppFeatures.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//find the selected item and store the value to send to next screen
strSelectedFeature = ((TextView) view).getText().toString();
//move to display screen
Intent switchActivity = new Intent(MainActivity.this,
NextActivity.class);
startActivity(switchActivity);
}
});
有没有办法在 ListView 中有一组项目和一个子项目,但又打算打开另一个活动?
【问题讨论】:
-
这个问题被否决了?不解释?如果你对这个问题投了反对票,我肯定想知道为什么。
标签: android android-intent android-listview