求助,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>
请问各位改怎么解决?