Android 列表视图可见性
我试图在用户单击布局时使listview可见。我已将setOnClickListener添加到布局中。但是当我单击布局时,listview不可见。你能帮我解决这个问题吗。下面是我的代码:Android 列表视图可见性,android,android-listview,visibility,onclicklistener,Android,Android Listview,Visibility,Onclicklistener,我试图在用户单击布局时使listview可见。我已将setOnClickListener添加到布局中。但是当我单击布局时,listview不可见。你能帮我解决这个问题吗。下面是我的代码: transparentListView = (ListView) findViewById(R.id.tarnsparent_list_view); LinearLayout lt = (LinearLayout)findViewById(R.id.layout); lt.setOnClickListen
transparentListView = (ListView) findViewById(R.id.tarnsparent_list_view);
LinearLayout lt = (LinearLayout)findViewById(R.id.layout);
lt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
System.out.println("On click listener");
transparentListView.setVisibility(View.VISIBLE);
for (int j=0;j<sectionListItems.size();j++)
{
System.out.println("section " + sectionListItems.get(j).toString());
}
ArrayAdapter<String> myarrayAdapter = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_list_item_1, sectionListItems);
for(int k = 0;k<myarrayAdapter.getCount();k++)
{
System.out.println("Adapter " + myarrayAdapter.getItem(k));
}
transparentListView.setAdapter(myarrayAdapter);
}
});
transparentListView=(ListView)findViewById(R.id.tarnsparent\u list\u视图);
LinearLayout lt=(LinearLayout)findViewById(R.id.layout);
lt.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
//TODO自动生成的方法存根
System.out.println(“单击侦听器”);
transparentListView.setVisibility(View.VISIBLE);
对于(intj=0;j更改如下表布局样式
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_parent" >
像这样更改表格布局样式
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_parent" >
u将表布局高度指定为匹配父项。因此,您无法看到它,因为它将占据整个屏幕。因此,请将其包装为内容或赋予它一些值。u将表布局高度指定为匹配父项。因此,您无法看到它,因为它将占据整个屏幕。因此,请将其包装为内容或赋予它一些值。发布您的布局xml alsoCa是否在日志中打印sectionListItems大小?是的,我可以在日志中看到log@Hardik这些是sectionListItem元素:section abe section abe1 section abe2 section abe3 section abe4 section abe5 section abe6 section abe7大小为8@user370305您好,我已经放置了View.OnClickListener,但仍然没有运气。发布布局xml也可以打印吗ionListItems在日志中的大小?是的,我可以在log@Hardik这些是sectionListItem元素:section abe section abe1 section abe2 section abe3 section abe4 section abe5 section abe6 section abe7大小为8@user370305嗨,我已经放了View.com,但还是没有运气。