CWAC MergeAdapter - https://github.com/commonsguy/cwac-merge을 사용하여 ListView
에 두 개의 데이터 어댑터를 추가하고 있습니다. 이와 비슷한 것 :ListView에서 하나의 데이터 어댑터에 대한 클릭 사용 안 함
MergeAdapter mergeAdapter = new MergeAdapter();
mergeAdapter.addAdapter(yourFirstAdapter);
mergeAdapter.addAdapter(yourSecondAdapter);
list.setAdapter(mergeAdapter);
또한 ListView
에 대한 항목 클릭 수신기를 설정합니다. 그러나 내가 원하는 것은 adapter1의 데이터 만 클릭 할 수 있어야한다는 것입니다. 이것을 어떻게 구현할 수 있습니까? - ROW2 -
ListView list = (ListView) findViewById(R.id.lv);
RelativeLayout secondAdapterlistRowLayout = (RelativeLayout) findViewById(R.id.secondrow);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long mallId) {
//go to the shops view
if (adapterView.equals(secondAdapterlistRowLayout)){
//do nothing
}
else {
Intent intent = new Intent(getActivity(), ShopActivity.class);
intent.putExtra("MALL_ID", (int) mallId);
startActivity(intent);
}
}
});
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0"
android:clickable="false"
android:id="@+id/secondrow">
....
</RelativeLayout>
은 기본적으로 내가이 작업을 수행 할 수 adapter2 : 무엇 내가 지금까지 가지고하는 것은 이것이다
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long mallId) {
if(R.id.secondrow is clicked){ then start a new activity }
}
}
'yourFirstAdapter'에 클릭 된 항목이 있는지 확인한 다음 일부 코드를 무시하고 onItemClick을 무시하십시오. –
해당 어댑터가 맞춤 설정되어 있습니까? 그렇다면'isEnabled'를 오버라이드하고 아이템을 클릭 할 수 없게하는 어댑터에서 false를 반환합니다. – Rohit5k2