亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

setOnItemClickListener() 不適用于 Fragment 中的

setOnItemClickListener() 不適用于 Fragment 中的

翻過高山走不出你 2023-10-19 21:44:48
你好,早上好,在我看來,我無法處理 setOnItemClickListener我正在嘗試創建一個在 gridview 中動態列出已安裝應用程序的應用程序。我能夠以 gridview 形式顯示應用程序,但無法使這些項目可單擊。當我點擊這些項目時什么也沒有發生。setOnItemClickListener 內的代碼不會在單擊事件時觸發。<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".Tab2profile">    <RelativeLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        tools:ignore="UselessParent">//my scrollview         <ScrollView            android:layout_width="match_parent"            android:fillViewport="true"            android:layout_height="match_parent">            <RelativeLayout                android:id="@+id/MainRLyout"                android:layout_width="match_parent"                android:orientation="vertical"                android:layout_height="wrap_content">                <RelativeLayout                    android:id="@+id/girislayout"                    android:layout_alignParentTop="true"                    android:layout_width="match_parent"                    android:layout_height="wrap_content">                </RelativeLayout>                </syr13.comapp4.Custum_Adapters.ExpandableHeightGridView>            </RelativeLayout>        </ScrollView>    </RelativeLayout></FrameLayout>
查看完整描述

1 回答

?
臨摹微笑

TA貢獻1982條經驗 獲得超2個贊

我認為你可以更改你的代碼

button.setOn Item ClickListener(this);

按鈕.setOnClickListener(this);

例如 :-


    public class MainActivity extends AppCompatActivity {

        @Override

        protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_main);

            Button button = findViewById(R.id.button);

            button.setOnClickListener(this);

        }

        @Override

        public void onClick(View v) {

            switch (v.getId())

            {

                case R.id.button:

                    //Do Something

                    break;

            }

        }

    }


查看完整回答
反對 回復 2023-10-19
  • 1 回答
  • 0 關注
  • 120 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號