求助,Listview点击item事件无响应

北野望 2016-11-26 06:49:42
想用ListView显示一列标题,结果能显示出来,但不能点击
public class RankList extends Activity {
private ListView bl;
private TextView bigtitle;
private RankService rankService = new RankService();

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.internet_result);
Bundle bundle = getIntent().getExtras();
String key = bundle.getString("key");
final String title = bundle.getString("title");
bl = (ListView) findViewById(R.id.bl);
bigtitle = (TextView) findViewById(R.id.bigtitle);
bl.setOnItemClickListener(new ItemClickEvent());
try {
bigtitle.setText(title);
List<HashMap<String, Object>> book_list = rankService.getDate(key);
SimpleAdapter adapter = new SimpleAdapter(this, book_list, R.layout.internet_result_list,
new String[]{"booklist"}, new int[]{R.id.rank_book});
bl.setAdapter(adapter);
} catch (Exception e) {
e.printStackTrace();
}
}

final class ItemClickEvent implements OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
HashMap<String, String> map = (HashMap<String, String>) arg0.getItemAtPosition(arg2);
String p = map.get("booklist");
Toast.makeText(RankList.this, "123", Toast.LENGTH_SHORT).show();
}
}
布局文件如下,只有TextView

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1">

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/rank_book"
android:textAlignment="center"
android:textSize="36sp" />
</LinearLayout>
</ScrollView>
请问各位改怎么解决?
...全文
190 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
北野望 2016-11-27
  • 打赏
  • 举报
回复
原来是listview下子控件只能用线性布局

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧