저는 목록 항목에 대한 내 사용자 정의보기를 추가 한 기본 ListView를 가지고 있지만 대부분이보기의 버튼은 클릭 할 수 없습니다. 버튼에 클릭 이벤트가 발생하면 Log.v를 출력하지만 클릭을 등록하기 전에 버튼을 약 12 번 눌러야합니다.버튼 안드로이드 안쪽에 ListView는 클릭에 응답하지 않습니다
다른 문제는 내가 갖고있는 것과 관련이 있습니다. 버튼을 누르면 애니메이션이 생겨서 그 아래에서 슬라이딩하는 메뉴가 나타납니다. 지금은보기에 대한 relativeLayout 개체를 얻기 위해 레이아웃 인플레이터를 사용하는 대신 뷰에 대한 사용자 지정 클래스를 만드는 것과 같은 여러 가지 방법을 시도했지만 아무 것도 올바르게 작동하지 않습니다. 나는 심지어 listview.getAdapter().notifyDataSetChanged();
을 사용해 보았지만, 애니메이션을 원할 때만 확장보기를위한 팝업 위치가 있습니다.
나는 어디에서나 검색했으며 가능한 유일한 해결책은 내 자신의 사용자 지정 목록보기를 다시 쓰거나 scrolllay를 사용하여 선형 레이아웃을 사용하는 것입니다. 후자는 쉽게 보이지만 나는 listview가 거의 최적화되어 있다고 생각하지 않는다.
모든 제안을 크게 ... 당신은 몇 가지 코드를 볼 필요가 있다면 알려 주시기 바랍니다,
감사 감사하겠습니다!
업데이트 : 새로운보기를 매번 작성해야하고 그래서 내가 해달라고 있도록
Holder hold;
convertView = friends.get(position);
hold = new Holder();
hold.pos = position;
convertView.setTag(hold);
return convertView;
기본적으로 내가 어댑터, 순간에, ArrayList<RelativeLayout>
을 전달합니다
가 getView()
이 포함 애니메이션은 아래로 스크롤 할 때 애니메이션 상태를 유지할 것입니다 ...
OnCreate()
이 활동을 위해이 코드를 사용하여 ArrayList<RelativeLayout>
을 설정했는데 이것은 ano THER 방법 나중에이 내가 사용하고있는 목록 항목입니다
RelativeLayout temp;
for(int i=0; i<30; i++){
temp = (RelativeLayout) inflater.inflate(R.layout.list_item, null);
final LinearLayout extraListItemInfo = (LinearLayout) temp.findViewById(R.id.extraListItemInfo);
Button infoBtn = (Button) temp.findViewById(R.id.infoBtn);
infoBtn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Log.v("ListItem", "Button has been clicked... ");
extraListItemInfo .setVisibility(View.VISIBLE);
ExpandAnimation closeAnim = new ExpandAnimation(extraListItemInfo , animHeight);
closeAnim.setDuration(750);
closeAnim.setFillAfter(true);
if(extraListItemInfo .getTag() == null || !extraListItemInfo .getTag().equals("expanded")){
extraListItemInfo .getLayoutParams().height = 0;
friendInfoList.startAnimation(closeAnim.expand());
extraListItemInfo .setTag("expanded");
}else if(extraListItemInfo .getTag().equals("expanded")){
extraListItemInfo .startAnimation(closeAnim.collapse());
extraListItemInfo .setTag("closed");
}
//((BaseAdapter) listview.getAdapter()).notifyDataSetChanged(); i tried it here once but then left it
//as the only action inside the listview's onitemclick()
}
});
listItems.add(temp);
}
비동기 작업 또는이 뷰가 일부 데이터를 포함하도록 뭔가 ... 같은 : 어떤 레이아웃 문제에 대한
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/darkgrey"
android:paddingBottom="5dp" >
<LinearLayout
android:id="@+id/extraListItemInfo "
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/listItemInfo"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="-10dp"
android:background="@color/grey"
android:orientation="vertical"
android:visibility="gone" >
<RelativeLayout
android:id="@+id/RelativeLayout04"
android:layout_width="match_parent"
android:layout_height="@dimen/activity_list_height"
android:layout_marginTop="5dp" >
<ImageView
android:id="@+id/ImageView04"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="@drawable/logo_d" />
<TextView
android:id="@+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/ImageView04"
android:text="TextView"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout03"
android:layout_width="match_parent"
android:layout_height="@dimen/activity_list_height" >
<ImageView
android:id="@+id/ImageView03"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="@drawable/logo_d" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/ImageView03"
android:text="TextView"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout02"
android:layout_width="match_parent"
android:layout_height="@dimen/activity_list_height" >
<ImageView
android:id="@+id/ImageView02"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="@drawable/logo_d" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/ImageView02"
android:text="TextView"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="@dimen/activity_list_height" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="@drawable/logo_d" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/imageView1"
android:text="TextView"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="@dimen/activity_list_height">
<ImageView
android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_margin="5dp"
android:src="@drawable/logo_d" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/ImageView01"
android:text="TextView"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/listItemInfo"
android:layout_width="wrap_content"
android:layout_height="95dp"
android:background="@drawable/friend_cell_background2x"
android:clickable="true" >
<RelativeLayout
android:id="@+id/leftLayout"
android:layout_width="90dp"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imgCompany"
android:layout_width="60dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:scaleType="centerInside"
android:src="@drawable/user2x" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:src="@drawable/online_indicator2s" />
</RelativeLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@+id/leftLayout"
android:background="@android:color/transparent"
android:gravity="left|center"
android:orientation="vertical"
android:paddingLeft="5dp" >
<TextView
android:id="@+id/lblCompanyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact Name"
android:textColor="@color/white"
android:textSize="18dp"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/lblReawrdDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Last Played Offer"
android:textColor="@color/white"
android:textSize="17dp" >
</TextView>
</LinearLayout>
<ImageView
android:id="@+id/imageView4"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="5dp"
android:src="@drawable/facebook_btn2x" />
<Button
android:id="@+id/infoBtn"
style="?android:attr/buttonStyleSmall"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/imageView4"
android:background="@drawable/info_btn2x"
android:clickable="true" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="13dp"
android:layout_toLeftOf="@+id/infoBtn"
android:text="Follows 30+"
android:textColor="@color/white"
android:textSize="11dp" />
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="75dp"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/textView2"
android:background="@drawable/fan_btn2x"
android:text="Fans 30+"
android:textColor="@color/white"
android:textSize="11dp" />
<ImageView
android:id="@+id/imageView5"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/imageView4"
android:src="@drawable/google_btn2x" />
</RelativeLayout>
</RelativeLayout>
미안 그 일을 할 수 읽기 어려운합니다 ...하지만 난
업데이트 2 감사합니다 ...이 너희들이 내 문제를 이해하는 데 도움이되기를 바랍니다 :
이 답변의 모든 일부 WA에 도움이되었습니다 y,하지만 먼저 해결해야 할 주요 문제는 buttonItem에서 처음 스크롤 한 다음 다시 버튼을 클릭 할 때까지 버튼이 클릭 이벤트를받지 않는 이유입니다. 누군가가 내가 생각 THAT에 대한 해결책은 다른 모든 요청으로 ... 스크린 샷
... 해결 덕분에 훨씬 쉽게,하지만이 장면은 삼성 갤럭시 탭 10.1과로 인해 촬영 한 기억 것 나 더 큰 화면에 대한 동일한 레이아웃을 사용하여, 그것은 내가 일반적으로 (모토로라 droid x 그 isnt 뿌리와 캔트 스크린 샷을 가져 가라.)
또 다른 업데이트 : 은 내가 클릭을 얻을 관리 및 애니메이션은 기본 어댑터 대신 ArrayAdapter와 확장에 의해 잘 작동합니다. 슬프게도 목록의 아래쪽 절반 만 클릭 할 수 있으므로 여전히 문제가 발생합니다. 목록의 상단 부분은 여전히 이상한 클릭 이벤트로 이전과 같이 작동합니다 ... 이번에 무슨 일이 일어나고 있는지에 대한 아이디어가 있습니까? 사용할 때 감사합니다 ...
클릭 수신기가 수신 대기하지 않는 이유에 대한 컨텍스트를 제공하려면 관련 코드를 포함하십시오. – Sam
어댑터의'getView()'코드는 무엇입니까? 또한 행을 팽창 시키려면 xml을 게시하십시오. –
귀하의 XML 파일에서 안드로이드 : focasable = false 나는 일할 수 있습니다 ... – DynamicMind