0

내 프로젝트에 FunDapter을 사용하고 있습니다. 내 레이아웃에 imagebutton을 추가하려고하면 다른 텍스트가 unclickable가됩니다. 아무 것도 클릭하지 않으면 아무 것도 할 수 없습니다.이 어댑터에 버튼을 추가 할 수 있습니까? 모든 것이 잘 작동 곳맞춤 어댑터에 버튼을 추가하는 방법은 무엇입니까?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:text="Isimsiz" 
    android:id="@+id/Housename" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginLeft="2dp" 
    android:clickable="false" 
    android:textColor="#241d1d" 
    android:layout_row="0" 
    android:layout_column="0" 
    android:layout_marginRight="2dp" 
    android:layout_marginTop="2dp" 
    android:layout_marginBottom="2dp" /> 



    <TextView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceSmall" 
    android:text="Aciklama Yok" 
    android:id="@+id/Desc" 
    android:layout_below="@+id/Housename" 
    android:clickable="false" 
    android:layout_alignStart="@+id/Housename" 
    android:textColor="#241d1d" 
    android:layout_row="1" 
    android:layout_column="0" 
    android:layout_marginLeft="2dp" 
    android:layout_marginRight="2dp" 
    android:layout_marginTop="2dp" 
    android:layout_marginBottom="2dp" 
    android:layout_alignEnd="@+id/Housename" /> 

    </RelativeLayout> 

내가 이미지 버튼 아무것도하여 ImageButton

<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imageButton" 
    android:layout_alignTop="@+id/Housename" 
    android:layout_alignParentEnd="true" 
    android:layout_alignBottom="@+id/Desc" 
    android:clickable="true" 
    android:onClick="berk" 
    /> 

제외하고 클릭 할 수없는 추가하면 list_layout 아래

입니다 그리고 이것은 내가 내 어댑터를 만들 클래스의 일부이다

public void processFinish(String s) { 
    productList = new JsonConverter<Product>().toArrayList(s, Product.class); 
    BindDictionary<Product> dict = new BindDictionary<Product>(); 
    dict.addStringField(R.id.Housename, new StringExtractor<Product>() { 
     @Override 
     public String getStringValue(Product product, int position) { 
      return product.HouseID; 
     } 
    }); 

    dict.addStringField(R.id.Desc, new StringExtractor<Product>() { 
     @Override 
     public String getStringValue(Product product, int position) { 
      return product.Desc; 
     } 
    }); 


    FunDapter<Product> adapter = new FunDapter<>(
    ListActivity.this, productList, R.layout.layout_list, dict); 

    lvProduct = (ListView)findViewById(R.id.lvProduct); 
    lvProduct.setAdapter(adapter); 
    lvProduct.setOnItemClickListener(this); 

} 

@Override 
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
    //do sth 
} 
public void berk(View v) { 
    //do sth 
} 

참고 : xml의 텍스트에 클릭 가능한 속성을 부여하면 레이아웃 XML을 가지고 놀면 모든 것이 멈추게됩니다. 어댑터 클래스에서

답변

0
First of all if u are using button or edit text in your adapter or row file Then every thing will get stop working . 
You should use 

1.Set descendant Focusablity="before Descendants" in the list view. 
2.Set window Soft Input Mode="adjust Pan" in the manifest 
3.Set list view.set Items Can Focus(true) 
+0

softinoutmode를 만들고이 두 라인을 추가했다. lvProduct.setItemsCanFocus (true); lvProduct.setDescendantFocusability (ViewGroup.FOCUS_BEFORE_DESCENDANTS); 아직도 버튼 작품 인 listrows는 – Wardruna

0

public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = getLayoutInflater(); View row = inflater.inflate(R.layout.vehicals_details_row, parent, false); Button deleteImageView = (Button) row.findViewById(R.id.DeleteImageView); deleteImageView.setOnClickListener(new OnClickListener() { public void onClick(View v) { //... } }); }

하지만이 문제가 얻을 수 - 클릭 할 수 없습니다 목록보기 행을. 해결 방법 :

  • 메이크업 ListView에 포커스 안드로이드 : 포커스 = "true"를

  • 버튼하지 포커스 안드로이드 : 포커스

+0

나는 그 코드가하는 것을 이해하지 못한다. 나는 비슷한 코드를 가지고 있지 않다. 나는 2 가지 집중적 인 솔루션을 만들었지 만 작동하지 않았다. – Wardruna

0

은 별도의 클릭을 제공해야 = "거짓" 모든보기에 대한 이벤트.

ImageButton에는 하위보기를 클릭 할 수있게 만드는 android : clickable = "true"가 있습니다. 하지만 다른보기는 클릭 할 수 없습니다.

텍스트 뷰의 클릭 이벤트에 대한 솔루션

textView.setOnClickListener (새 OnClickListener를() {
공공 무효 온 클릭 (보기 V) {
// ... }
});

이 도움이 되었으면 좋겠 클릭 = "true"로 :하여 ImageButton
유사

안드로이드 제거합니다.