Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在4.1中的弹出窗口中无法在列表视图中选择行,但在Android 5.0中工作大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的页面中有一个弹出窗口,其中有一个表视图.我已经在一个单独的xml中创建了弹出窗口的设计,并在我的主页上点击了一些按钮.弹出窗口具有列表视图,每行具有图像和文本视图.我不能在 Android 4.1中的列表视图中获得行选择,但它在5.0中正常工作.任何人都可以提出我的解决方案?
列表显示
<ListView android:id="@+id/lstSites"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:fastScrollEnabled="true"
        android:layout_margin="5dp"
        android:descendantFocusability="blocksDescendants"></ListView>
</LinearLayout>

列表项目:

<LinearLayout xmlns:android="http://scheR_475_11845@as.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:focusableInTouchMode="false">
<ImageView
    android:id="@+id/thumbImage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:layout_marginRight="10dp"
    android:focusable="false"
    android:focusableInTouchMode="false"/>
<TextView
    android:id="@+id/tvSite"
    android:textSize="20dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:text="Name"
    android:focusable="false"
    android:focusableInTouchMode="false"/>

添加行点击列表:

lstSiteMenu = (ListView) popupView.findViewById(R.id.lstSites);

            adapter = new MenuItemsAdapter(SiteActivity.this,arrMenu);
            // Attach the adapter to a ListView
            lstSiteMenu.setAdapter(adapter);
            lstSiteMenu.setOnItemClickListener(new AdapterView.onItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent,View view,final int position,long id) {
            }

解决方法

尝试所有的解决方案:
popupwindow.setFocuSALE(true);
listView xml : "android:focusable="true"

不要使用lstSiteMenu.setOnItemClickListener
而是转到你的Adapters getView并添加

convertView.setOnClickListener

希望会帮助你!

大佬总结

以上是大佬教程为你收集整理的在4.1中的弹出窗口中无法在列表视图中选择行,但在Android 5.0中工作全部内容,希望文章能够帮你解决在4.1中的弹出窗口中无法在列表视图中选择行,但在Android 5.0中工作所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。