I can not solve the problem with not working setOnItemClickListener().
(API minSdkVersion 19, targetSdkVersion 21, compile 'com.android.support:appcompat-v7:21.0.3')
I tried to put in different places:
android:descendantFocusability="blocksDescendants"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:textIsSelectable="false"
categoriesListView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
my fragment where I set listview
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.gallery_tab_categories, container, false);
super.onCreate(savedInstanceState);
categoriesListView = (ListView) view.findViewById(R.id.listViewCategories);
categoriesListView.setAdapter( new GalleryCategoriesListAdapter( getActivity(), CATEGORIES_DATA ) );
//dbHandler = new ShoppingListDatabaseHandler(getActivity());
categoriesListView.setLongClickable(true);
final GalleryCategoriesListAdapter itemAdapter = new GalleryCategoriesListAdapter(getActivity(), CATEGORIES_DATA);
registerForContextMenu(categoriesListView);
categoriesListView.setAdapter(itemAdapter);
//categoriesListView.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); //getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
categoriesListView.setOnItemClickListener(new AdapterView.setOnItemClickListener() {
#Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
clickedItemIndex = position;
return false;
}
});
//if (dbHandler.getItemsCount() != 0){CATEGORIES_DATA.addAll(dbHandler.getAllItems());
return view;
}
my xml with listview
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical" >
<ListView
android:id="#+id/listViewCategories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:focusableInTouchMode="false" />
<!--android:focusable="false"-->
<!--android:clickable="false"-->
xml with single item
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical" >
<!--android:autoLink="all"-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/itemCategoryName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall" />
<!--android:descendantFocusability="blocksDescendants"-->
<!--android:clickable="false"-->
<!--android:focusable="false"-->
<!--android:focusableInTouchMode="false"-->
<!--android:textIsSelectable="false"-->
Maybe I tried too many things and make my code not clear
You must delete this.
android: enfocable = "false"
android: focusableInTouchMode = "false"
//try with this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:gravity="center_vertical" >
<ListView
android:id="#+id/listViewCategories"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<LinearLayout/>
if you will specify the listview that events happen to the children, you will not click on item
I solved this.
I changed this fragment:
categoriesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
}
});
Related
I implemented my custom list but when I click an element of my list a Toast message should be displayed. It looks like that the setOnItemClickListener does not work.
Here there is the code of of my fragment layout in which there is my ListView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<ListView
android:id="#+id/listSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:focusable="false"/>
</LinearLayout>
here there is the structure of my list (each single line)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/imageContact"
android:layout_width="60dp"
android:layout_height="60dp"
android:padding="5dp"
android:focusable="false"/>
<TextView
android:id="#+id/nameSurnameContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:padding="2dp"
android:textColor="#33CC33"
android:focusable="false"/>
<TextView
android:id="#+id/idContact"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="invisible"
android:focusable="false"
/>
</LinearLayout>
</LinearLayout>
and here there is the mothod of my fragment that creates the layout and populate the list
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedBundle) {
View firstAccessView;
if(savedBundle==null) {
firstAccessView = inflater.inflate(R.layout.search_fragment_layout, null);
for(int i=0; i<8; i++){
Contact c = new Contact(idContact[i], nameSurname[i], facebookId[i], timeStamp[i]);
this.rows.add(c);
}
adapter = new SearchListAdapter(getActivity(), this.rows);
list = (ListView) firstAccessView.findViewById(R.id.listSearch);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getActivity().getApplicationContext(), "item selected", Toast.LENGTH_SHORT).show();
}
});
list.setOnScrollListener(this);
}else{
firstAccessView = getView();
}
return firstAccessView;
}
is there something that I missed in the xml files of in the Fragment file?
Remove android:focusable="false" from ListView.
android:focusable="false"
Remove this line from your listview xml file
i am trying to make list view with clickable items, and every list_item must consist 2 clickable buttons.
But if i add buttons to item layout, iten click listener stops to work...
here is my item_layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="center">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp">
<com.pkmmte.view.CircularImageView
android:id="#+id/friends_new_photo_circularImageView"
android:layout_gravity="center"
android:layout_width="#dimen/user_friends_width"
android:layout_height="#dimen/user_friends_height"
android:src="#mipmap/ic_launcher"
app:border="true"
app:border_color="#EEEEEE"
app:border_width="2dp"
app:shadow="true"/>
<ImageView
android:id="#+id/friends_new_online_status_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/online_status"
android:layout_alignBottom="#+id/friends_new_photo_circularImageView"
android:layout_alignRight="#+id/friends_new_photo_circularImageView"
android:layout_marginRight="8dp"
android:layout_marginBottom="5dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="#+id/friends_new_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textStyle="bold"/>
<ImageView
android:id="#+id/friends_new_rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="#drawable/stars"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:onClick="true"
android:text="Add"/>
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:onClick="true"
android:text="Dismiss"/>
</LinearLayout>
</LinearLayout>
here is fragment layout (with listView):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview_friends"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/ListViewStyle"/>
</LinearLayout>
and here is my fragment with onCreateView and onItemClickListener:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_friends_listview, container, false);
ButterKnife.inject(this, rootView);
String[] mNames = {
"Example 1",
"Example 2"
};
mFriendsAdapter = new FriendsAdapter(getActivity(), null, 0);
List<String> mList = new ArrayList<>(Arrays.asList(mNames));
ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(
getActivity(),
R.layout.list_item_friends_new,
R.id.friends_new_name,
mList
);
mListView.setOnItemClickListener(this);
mListView.setAdapter(mAdapter);
return rootView;
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
FriendsFragment.openCurrentUser(getActivity());
}
So here is the question:
is it possible to make clickable listItems with clickable buttons?
and if its true, than how to do it? if it false - maybe you have some other solution?
I just found solution from here..but by deep clicking...
If any row item of list contains focusable or clickable view then OnItemClickListener won't work.
The row item must have a param like android:descendantFocusability="blocksDescendants".
here you can see example, how your list item should look like
row_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical" >
// your other widgets here
</LinearLayout>
or add these two lines for the inner views
android:focusable="false"
android:focusableInTouchMode="false"
remove onclick attribute like bellow in your code...
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:onClick="true"//remove this
android:text="Add"/>
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:onClick="true" //remove this
android:text="Dismiss"/>
</LinearLayout>
and write your adapter as
ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(
getActivity(),
R.layout.list_item_friends_new,
R.id.friends_new_name,
mList
){
View.OnClickListener listener = new View.OnClickListener() {
#Override
public void onClick(View v) {
//your action on button click
}
};
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
Button button = (Button) view.findViewById(R.id.yourButtonID);
button.setOnClickListener(listener);
return view;
}
};
I display some items as a list and I was wondering whether there was a way to add a little dropdown to the right of the screen for each item in the list giving the options of delete/edit.
Is that possible? Rigth now I list things like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include android:id="#+id/header"
layout="#layout/header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
<TextView
android:id="#+id/no_problems"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter the business(es) you want to plan or choose from your existing list."
/>
<ListView
android:id="#android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#+id/label"
android:textSize="20px" >
</ListView>
<Button
android:id="#+id/add_problem_ok"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/light_best_blue"
android:text="Plan a New Business"
android:layout_marginTop ="15dp"
/>
</LinearLayout>
and in the listView I have this:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
Thanks!
If u want to look good then use quickaction-dialog for Option Menu.
here the whole example quickaction-dialog
Just add spinner in ur list item layout, then set adapter to tat spinner with in getView() method.
for ex. ur list_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="#+id/nameTV" android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
<Spinner android:id="#+id/actionSP" android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
then UR getView()
#Override
public View getView(int position, View view, ViewGroup viewGroup) {
final ViewHolder viewHolder;
if (view == null) {
viewHolder = new ViewHolder();
view = mInflater.inflate(R.layout.list_item,
null);
viewHolder.nameTV = (TextView) view
.findViewById(R.id.nameTV);
viewHolder.actionSP = (Spinner) view
.findViewById(R.id.actionSP);
ArrayAdapter<String> reasonAdapter = new ArrayAdapter<String>(
mApplication, android.R.layout.simple_spinner_item,
mYourActionsArray);
reasonAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
viewHolder.actionSP.setAdapter(reasonAdapter);
viewHolder.actionSP
.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0,
View arg1, int position, long arg3) {
}
});
view.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) view.getTag();
}
viewHolder.nameTV.setText("Some Value");
return view;
}
ViewHolder class
class ViewHolder {
TextView nameTV;
Spinner actionSP;
}
This is probably a stupid question.
I know I can wrap a ListView in ViewFlipper, but can we wrap individual ListView Items in a ViewFlipper? For instance, the latest Twitter app uses a ListView to display Tweets. It also allows you to set settings on individual items by sliding the tweet out of the way exposing the setting option icons below. Is this a custom implementation or do we have the ability to create something similar using ListView and ViewFlipper? Thanks, any advice is appreciated!
I've spent some time on this and got the ListView to display additional content via the ViewFlipper. However, the view only seems to "flip" on the last item in the ListView. How do I get each item to flip when clicked? Here's some code:
row.xml
<?xml version="1.0" encoding="utf-8"?>
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/flipper" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/toptext" android:layout_width="fill_parent"
android:layout_height="0dip" android:layout_weight="1"
android:gravity="center_vertical" />
<TextView android:id="#+id/bottomtext" android:layout_width="fill_parent"
android:layout_height="0dip" android:layout_weight="1"
android:gravity="center_vertical" />
</ViewFlipper>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#id/android:list" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
ListActivityView.java - extends ListActivity
...
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
...
}
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// doesn't matter which line is clicked
// only the last item in the ListView displays the bottomText
viewFlipper.showNext();
}
ListingAdapter.java - extends ArrayAdapter
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
viewFlipper = (ViewFlipper) v.findViewById(R.id.flipper);
}
If I am getting your question correct - you can use ViewFlipper inside a layout that defines a row in your list and init it the way you like when rendering corresponding view
Below code helps you achieve a requirement for having a view flipper in list view with invidual row flipping
## xml file ##
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/regularLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="#dimen/activity_horizontal_margin">
<ViewFlipper
android:id="#+id/row_item_flipper"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:id="#+id/list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Regular Layout"
android:textSize="28sp" />
<Button
android:text="Flip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/front_button" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<TextView
android:id="#+id/backTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Flip row done"
android:textSize="18sp" />
<Button
android:text="Flip back"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/back_button" />
</LinearLayout>
</ViewFlipper>
</LinearLayout>
----------
## Java code ##
#Override
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_item, parent, false);
return new ItemViewHolder(itemView);
}
#Override
public void onBindViewHolder(final ItemViewHolder holder, int position) {
final CustomItem data = dataList.get(position);
holder.regularLayout.setVisibility(View.VISIBLE);
holder.swipeLayout.setVisibility(View.GONE);
holder.listItem.setText(data.dataItemValue );
holder.backTextView.setText(data.dataItemValue + " position : "+ position);
holder.viewFlipper.setFlipInterval(0);
holder.viewFlipper.setInAnimation(null);
holder.viewFlipper.setOutAnimation(null);
if(holder.viewFlipper.getDisplayedChild()==0 && data.isFlipON){
holder.viewFlipper.setDisplayedChild(1);
} else if(holder.viewFlipper.getDisplayedChild()==1 && !data.isFlipON){
holder.viewFlipper.setDisplayedChild(0);
}else if(data.isFlipON){
holder.viewFlipper.setDisplayedChild(1);
}else{
holder.viewFlipper.setDisplayedChild(0);
}
holder.frontButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
AnimationFactory.flipTransition(holder.viewFlipper, AnimationFactory.FlipDirection.LEFT_RIGHT);
data.isFlipON = true;
}
});
holder.backButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
data.isFlipON = false;
AnimationFactory.flipTransition(holder.viewFlipper, AnimationFactory.FlipDirection.LEFT_RIGHT);
}
});
}
I have an Activity which extends ListView
The ListView that I use is an extension of ArrayAdapter and each row of the ListView primarily consists of a WebView
The problem is that touching the WebView does not call OnListItemClick.
Any thoughts on how I can be able to touch the webview and call OnListItemClick?
Or is there something else that I'm doing wrong?
Thanks!
Here is a skeleton of the Activity class, along with the relevant XML files for the layout
PS, I've tried setting android:clickable="false" in my layout, but this doesn't let me click on the rows of my ListView.
Interestingly, I can still scroll through the list, but I just can't click!
public class ListOfItemsFromTopicActivity extends ListActivity {
private Topic t;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.items_from_topic_skeleton);
TopicFactory tf = new TopicFactory();
t = tf.build_topic(3);
ListView itemlist = getListView();
ListOfItemsAdapter adapter = new ListOfItemsAdapter(this, R.layout.items_from_topic_row, t.getItems());
itemlist.setAdapter(adapter);
}
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// do some stuff that never gets done
}
private class ListOfItemsAdapter extends ArrayAdapter<Item> {
private ArrayList<Item> items;
private int text_view_resource_id;
private LayoutInflater layout_inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
public ListOfItemsAdapter(Context context, int a_text_view_resource_id, ArrayList<Item> some_items) {
super(context, a_text_view_resource_id, some_items);
this.items = some_items;
this.text_view_resource_id = a_text_view_resource_id;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = layout_inflater.inflate(this.text_view_resource_id, null);
Item o = items.get(position);
WebView page = (WebView)v.findViewById(R.id.item);
page.loadDataWithBaseURL("fake://a/bcde", o.getShort_title(), "text/html", "utf-8", "");
return v;
}
}
}
items_from_topic_skeleton.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
>
<TextView
android:background="#drawable/blackgrad"
android:gravity="center"
android:id="#+id/section_title"
android:layout_height="50dip"
android:layout_width="fill_parent"
android:textColor="#ffffff"
android:textSize="18sp"
/>
<ListView
android:background="#ffffff"
android:cacheColorHint="#ffffffff"
android:id="#android:id/list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
/>
</LinearLayout>
items_from_topic_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:padding="5dip"
>
<LinearLayout
android:gravity="center"
android:layout_height="60dip"
android:layout_width="fill_parent"
android:orientation="horizontal"
>
<LinearLayout
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_width="fill_parent"
android:minHeight="55dip"
android:orientation="horizontal"
android:padding="5dip"
>
<WebView
android:id="#+id/item"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:scrollbars="none"
/>
</LinearLayout>
<ImageView
android:id="#+id/disclosure"
android:layout_height="29dip"
android:layout_width="29dip"
android:paddingRight="5dip"
android:src="#drawable/disclosure"
/>
</LinearLayout>
</LinearLayout>
If you add a focusable element to a ListView, it causes the ListView items to no longer be selectable. Try setting android:clickable = false on your WebView.
Just make your onTouch event to do whatever you want.
e.g: My list item consists of TextView, WebView and Linear layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="66dp"
android:orientation="vertical"
android:id="#+id/layout">
<TextView
android:layout_width="wrap_content"
android:id="#+id/textView"
android:layout_height="wrap_content" />
<WebView
android:id="#+id/webvie"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</WebView>
</LinearLayout>
and I want to perform on click action - on the whole listitem.
holder.layout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//do stuff
}
});
But when I run my app, only texview is clickable. What to do? Set up onTouch listener on webView:
holder.webView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
holder.layout.callOnClick();
return true;
}
});
supports only API 15+ tough...