나는 listview를 가지고 있으며, 나는 그 Listview를 위해 OnItemClickListener를 사용하고 있습니다. 동시에, 내 사용자 지정 어댑터의 getview 메서드에서 전체 행보기에 대한 onclicklistener 사용하고 있습니다. 그리고 사용자 지정 어댑터 Onclicklisnter 사용할 때 listview 내 OnItemClickListener가 트리거되지 않은 것을 알았습니다. 이 두 리스너를 동시에 사용하고 싶습니다. 아무도 내가 그것을 도울 수 있습니까? 미리 감사드립니다.Onitemclick Listener가 Listview에서 트리거되지 않았습니다.
내 목록보기 리스너,
list_specialists.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
HashMap<String, String> trends_data= new HashMap<String, String>();
trends_data = specobj.get(position);
specialist.setText(trends_data.get(KEY_SPEC_TITLE));
new GetTime(BookingActivity.this).execute();
}
});
및 사용자 정의 어댑터 안에 내의 getView 방법,
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = convertView;
final ViewHolder holder;
if (rowView == null) {
rowView = inflater.inflate(R.layout.row_timeslot, parent, false);
holder = new ViewHolder();
holder.title = (TextView) rowView.findViewById(R.id.textView2);
holder.layout = (RelativeLayout) rowView
.findViewById(R.id.relativeLayout1);
holder.check = (org.holoeverywhere.widget.CheckBox) rowView
.findViewById(R.id.checkBox1);
rowView.setTag(holder);
} else {
holder = (ViewHolder) rowView.getTag();
}
HashMap<String, String> trends_data = new HashMap<String, String>();
trends_data = trendsobj.get(position);
holder.check.setId(position);
holder.check.setChecked(checkarry[position]);
// for managing the state of the boolean
// array according to the state of the
// CheckBox
holder.check.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
for (int i = 0; i < checkarry.length; i++) {
if (position == i) {
checkarry[i] = true;
} else {
checkarry[i] = false;
}
RefreshList();
}
}
});
holder.layout.setOnClickListener(new View.OnClickListener() { // Here I am using onclicklistener for rows's parent layout.
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
for (int i = 0; i < checkarry.length; i++) {
if (position == i) {
checkarry[i] = true;
} else {
checkarry[i] = false;
}
RefreshList();
}
}
});
holder.title.setText(trends_data.get(BookingActivity.KEY_TIME_TITLE));
return rowView;
}
rowlayout XML 파일 ...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:focusable="false"
android:background="@drawable/list_selector"
android:orientation="vertical"
android:padding="16dp" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@+id/activity_googlecards_card_imageview"
android:text="Rate "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#757572" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/textView3"
android:text="AED 200.00"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/mainservice" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/activity_googlecards_card_imageview"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/activity_googlecards_card_imageview"
android:gravity="center"
android:text="Specialist Name"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#6945B2"
android:textStyle="bold" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/activity_googlecards_card_imageview"
android:layout_alignParentRight="true"
android:focusable="false"
android:focusableInTouchMode="false" />
<ImageView
android:id="@+id/activity_googlecards_card_imageview"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="@drawable/list_dummy" />
</RelativeLayout>*
모든 ListRow 뷰를 'android : Focusable = fale'로 설정 했습니까? – SilentKiller
내가 아는 한, 그건 불가능합니다. – SKK
@SilentKiller가 작동하지 않습니다. –