久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    阻止后代時關注ListView中的EditText(Android)

    Focus on EditText in ListView when block descendants (Android)(阻止后代時關注ListView中的EditText(Android))
    本文介紹了阻止后代時關注ListView中的EditText(Android)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

    問題描述

    我有一個自定義的 ListView.每行都有一個 EditText、Buttons &文本視圖.為了使 ListView 項目可點擊,我為行布局保留了 android:descendantFocusability="blocksDescendants".如果我不保留 descendantFocusability,我將無法為 onItemClick 實施操作.如果我保留 descendantFocusability,則我所在行中的 EditText 不會獲得焦點.我希望 EditText 可聚焦,并且我應該能夠單擊每一行以導航到另一個 Activity.任何人都可以在這方面幫助我.謝謝大家.

    I have a customized ListView. Each row has an EditText, Buttons & TextView. In order to make the ListView items clickable I have kept android:descendantFocusability="blocksDescendants" for row layout. If I don't keep the descendantFocusability I am not able to implement an action for onItemClick. If I keep descendantFocusability the EditTextwhich is present in my row is not gaining focus. I want the EditText focusable and also I should be able to click on each row to navigate to another Activity. Can anyone please help me in this. Thanks all.

    在 EditText 的 CustomAdapter 中,我嘗試將 onTouchListeneronClickListener 保留在我 requestFocus 的位置,但這似乎不起作用.

    Edit : In the CustomAdapter for EditText, I tried keeping onTouchListenerand also onClickListenerwhere I requestFocus but that does not seem to work.

    行.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/recentrowLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/margin_left_5"
    android:clickable="true"
    tools:ignore="UseCompoundDrawables,HardcodedText,ContentDescription,UselessParent" >
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/edit_text_bg"
        android:padding="@dimen/margin_left_5" >
    
        <RelativeLayout
            android:id="@+id/rl1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
    
            <ImageView
                android:id="@+id/addSubscribe"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true" />
    
            <TextView
                android:id="@+id/flikart_textview"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:text="FLIKART"
                android:textColor="@color/gray"
                android:textSize="@dimen/medium_text_size" />
    
            <ImageView
                android:id="@+id/addToFav"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true" />
        </RelativeLayout>
    
        <LinearLayout
            android:id="@+id/rl2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/rl1"
            android:layout_marginLeft="@dimen/margin_30"
            android:layout_marginRight="@dimen/margin_30"
            android:layout_marginTop="10dp"
            android:gravity="center"
            android:orientation="vertical" >
    
            <TextView
                android:id="@+id/text_desciption"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:gravity="center_horizontal"
                android:lines="2"
                android:text="20% off on Smart Phones and basic Handsets has upto 50% OFF only"
                android:textColor="@color/blue" />
    
            <TextView
                android:id="@+id/text_desciption2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:lines="1"
                android:text="somethign something,......."
                android:textColor="@color/gray" />
    
            <TextView
                android:id="@+id/couponTypeText"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/margin_left_10"
                android:background="@drawable/button_bg"
                android:gravity="center"
                android:padding="@dimen/margin_left_10"
                android:text="STEAL THE DEAL"
                android:textColor="@color/white"
                android:textSize="@dimen/little_small_text_size" />
        </LinearLayout>
    
        <RelativeLayout
            android:id="@+id/rl3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/rl2"
            android:layout_marginTop="@dimen/margin_left_10" >
    
            <TextView
                android:id="@+id/text_offer_expiry"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="@dimen/margin_left_5"
                android:text="Ends 10 days"
                android:textColor="@color/red"
                android:textSize="16sp" />
    
            <RelativeLayout
                android:id="@+id/rightLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="5dp" >
    
                <ImageView
                    android:id="@+id/comment_image_total"
                    android:layout_width="@dimen/dimenstion_25"
                    android:layout_height="@dimen/dimenstion_20"
                    android:background="@drawable/comments" />
    
                <TextView
                    android:id="@+id/text_comments"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@id/comment_image_total"
                    android:text="100 Comments"
                    android:textColor="@color/gray"
                    android:textSize="16sp" />
            </RelativeLayout>
    
            <RelativeLayout
                android:id="@+id/ll2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_toLeftOf="@id/rightLayout"
                android:layout_toRightOf="@id/text_offer_expiry"
                android:gravity="center_horizontal" >
    
                <ImageView
                    android:id="@+id/like_image_total"
                    android:layout_width="@dimen/dimenstion_25"
                    android:layout_height="@dimen/dimenstion_25"
                    android:background="@drawable/like" />
    
                <TextView
                    android:id="@+id/text_total_likes"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_toRightOf="@id/like_image_total"
                    android:text="999 Likes"
                    android:textColor="@color/gray"
                    android:textSize="16sp" />
            </RelativeLayout>
        </RelativeLayout>
    
        <View
            android:id="@+id/view"
            android:layout_width="fill_parent"
            android:layout_height="4dp"
            android:layout_below="@id/rl3"
            android:layout_marginTop="@dimen/margin_5"
            android:background="@color/purple_clor" />
    
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="@dimen/title_bar_height"
            android:layout_below="@id/view"
            android:layout_centerVertical="true"
            android:layout_marginTop="@dimen/margin_5" >
    
            <RelativeLayout
                android:id="@+id/likesLayout"
                android:layout_width="@dimen/dimenstion_40"
                android:layout_height="@dimen/dimenstion_40"
                android:layout_centerVertical="true"
                android:background="@drawable/unratedbkg" >
    
                <Button
                    android:id="@+id/likesBtn"
                    android:layout_width="@dimen/dimenstion_30"
                    android:layout_height="@dimen/dimenstion_30"
                    android:layout_centerInParent="true"
                    android:background="@drawable/unrated" />
            </RelativeLayout>
    
            <RelativeLayout
                android:id="@+id/footermain"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/dimenstion_40"
                android:layout_centerVertical="true"
                android:layout_toRightOf="@id/likesLayout"
                android:background="@color/white" >
    
                <RelativeLayout
                    android:id="@+id/animLayout"
                    android:layout_width="100dp"
                    android:layout_height="@dimen/dimenstion_40"
                    android:layout_marginLeft="10dp"
                    android:layout_toRightOf="@id/likesLayout"
                    android:background="@drawable/ratingbkg"
                    android:visibility="gone" >
    
                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_margin="@dimen/margin_5" >
    
                        <ImageView
                            android:id="@+id/like_image"
                            android:layout_width="@dimen/dimenstion_30"
                            android:layout_height="@dimen/dimenstion_30"
                            android:layout_centerInParent="true"
                            android:background="@drawable/like" />
                    </RelativeLayout>
    
                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_margin="@dimen/margin_5" >
    
                        <ImageView
                            android:id="@+id/dislike_image"
                            android:layout_width="@dimen/dimenstion_30"
                            android:layout_height="@dimen/dimenstion_30"
                            android:layout_centerInParent="true"
                            android:background="@drawable/dislike" />
                    </RelativeLayout>
                </RelativeLayout>
    
                <EditText
                    android:id="@+id/add_comment"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginLeft="5dp"
                    android:layout_toRightOf="@id/animLayout"
                    android:focusable="false"
                    android:focusableInTouchMode="false"
                    android:hint="Add Comment"
                    android:inputType="text" />
            </RelativeLayout>
        </RelativeLayout>
    </RelativeLayout>
    
    </LinearLayout>
    

    推薦答案

    請不要使用 setOnItemClickListener 進行項目點擊.. 我認為你應該在適配器方法中使用項目視圖點擊

    please Don't use setOnItemClickListener for item click .. i think that you should be use item view click inside adapter method

    convertView.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    Toast.makeText(context, "click item",Toast.LENGTH_LONG).show();
                }
            });
    

    從主列表項布局中刪除它

    Remove this from main list item layout

    android:descendantFocusability="blocksDescendants" 
    

    感謝并享受這段代碼!

    這篇關于阻止后代時關注ListView中的EditText(Android)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

    【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

    相關文檔推薦

    EditText: Disable Paste/Replace menu pop-up on Text Selection Handler click event(EditText:禁用文本選擇處理程序單擊事件上的粘貼/替換菜單彈出)
    Multiline EditText with Done SoftInput Action Label on 2.3(2.3 上帶有完成 SoftInput 操作標簽的多行 EditText)
    How to detect the swipe left or Right in Android?(如何在 Android 中檢測向左或向右滑動?)
    Prevent dialog dismissal on screen rotation in Android(防止在Android中的屏幕旋轉對話框解除)
    How do I handle ImeOptions#39; done button click?(如何處理 ImeOptions 的完成按鈕點擊?)
    How do you set EditText to only accept numeric values in Android?(您如何將 EditText 設置為僅接受 Android 中的數值?)
    主站蜘蛛池模板: 精品欧美激情精品一区 | 国产成人免费在线观看 | 欧美久久久久久久久 | 中文字幕91av | 狠狠干夜夜草 | 一区二区三区精品在线 | 国产精品永久免费视频 | 成人国产精品免费观看视频 | 中国毛片免费 | 91久久| 91精品国产乱码久久久久久久 | 亚洲激情av | www.成人久久 | 久久国产精品免费一区二区三区 | 亚洲精品视频在线看 | 天天av天天好逼 | 一级免费毛片 | 日韩一级欧美一级 | 久久午夜国产精品www忘忧草 | 国产福利视频 | 最近最新中文字幕 | 国产一区二区久久 | 精品久久一区 | 精品久久久久久亚洲综合网 | 精品日本久久久久久久久久 | 99免费视频 | 天堂素人约啪 | 婷婷色婷婷 | 一区二区三区视频在线 | 国产精品久久久久久久久久尿 | 日韩高清国产一区在线 | 久久免费精品 | 一区二区三区日 | 欧美男人天堂 | 精品综合视频 | 麻豆91精品91久久久 | 中文福利视频 | 国产精品91视频 | 97精品超碰一区二区三区 | 综合自拍 | www.婷婷 |