Whenever I use a base adapter to add a view to a gallery it causes the EditText from within the view to not allow text input, it focuses and the keyboard appears but when I enter text it doesn't appear. The EditText type is numberDecimal.
I have tried setting the content view of MainActivity to ap_overview_add and the EditText works fine.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.mwapps.baseadaptertest.MainActivity">
<Gallery
android:id="#+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:padding="20dp" />
</RelativeLayout>
ap_overview_add.xml
<?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="match_parent"
android:orientation="vertical"
android:id="#+id/ap_overview_add_LL"
android:gravity="center">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/ap_et_add"
android:inputType="numberDecimal"
android:padding="10dp"
android:backgroundTint="#color/abc_secondary_text_material_light"
android:imeOptions="actionSend"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:layout_weight=".75"
android:clickable="true"
android:text="300"
android:focusable="true"
android:focusableInTouchMode="true" />
</LinearLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity {
Gallery gallery;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gallery = (Gallery) findViewById(R.id.gallery1);
gallery.setAdapter(new GalleryImageAdapter(this));
}
}
GalleryImageAdapter.java
public class GalleryImageAdapter extends BaseAdapter {
Context mContext;
LayoutInflater inflater;
public GalleryImageAdapter(Context context)
{
mContext = context;
}
public int getCount() {
return 1;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
// Override this method according to your need
public View getView(int index, View view, ViewGroup viewGroup)
{
// TODO Auto-generated method stub
inflater = LayoutInflater.from(mContext);
View tab;
tab = inflater.inflate(R.layout.ap_overview_add, viewGroup, false);
return tab;
}
}
I've looked at other questions similar and nothing has worked, including trying to change the softinput mode, what is causing the text to not be entered?
Edit: If the inputType is changed to text it allows input
Edit 2: If the inputtype is set to numberDecimal, numbers cannot be entered but things like commas can be, so it looks like it's not accepting numbers
You can use ViewPager instead of Gallery as suggested in developer.android.com/reference/android/widget/Gallery.html
to make it work
Related
I want to display a single row of 5 images which then I can click on, this is what I hope to get:
[1][2][3][4][5]
This is what I actually get:"____" is a large, long blank area
[1]________________________
[2]________________________
[3]________________________
[4]________________________
[5]________________________
At first I thought there was something up with the orientation so I tried both "horizontal" and "vertical" but nothing worked.
Here is the adaptor code:
public class CustomTopGridMenuAdaptor extends BaseAdapter {
private Context mContext;
private final int[] gridViewImageId;
private ImageView imageViewAndroid;
public CustomTopGridMenuAdaptor(Context context, int[] gridViewImageId) {
mContext = context;
this.gridViewImageId = gridViewImageId;}
#Override
public int getCount() {
return gridViewImageId.length;
}
#Override
public Object getItem(int i) {
return null;
}
public void setImageSource (int i,ImageView v){
imageViewAndroid.setImageResource(gridViewImageId[i]);
}
#Override
public long getItemId(int i) {
return 0;
}
#Override
public View getView(int i, View convertView, ViewGroup parent) {
View gridViewAndroid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
gridViewAndroid = new View(mContext);
gridViewAndroid = inflater.inflate(R.layout.android_custom_gridview_layout_top, null);
imageViewAndroid = (ImageView)
gridViewAndroid.findViewById(R.id.android_gridview_image_top);
setImageSource(i,imageViewAndroid);
} else {
gridViewAndroid = (View) convertView;
}
return gridViewAndroid;
}
}
As far as it goes the adaptor is working just fine.
This is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/android_custom_gridview_layout_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:id="#+id/android_gridview_image_top"
android:layout_width="50dp"
android:layout_height="50dp"/>
</LinearLayout>
This is the xml segment in the activity layout, where the menu will be displayed:
<GridView
android:id="#+id/android_gridview_menu_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="196dp">
Can you tell me why it's not working?
Use the android:numColumns="2" in your GridView if you want 5 then change the android:numColumns="5"
<GridView
android:id="#+id/android_gridview_menu_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:numColumns="2"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="196dp">
I don't think that gridviews can be made horizontally scrollable. Android has provided HorizontalScrollView it will scroll your view horizontaly. try this.
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<GridView
android:id="#+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</GridView>
</LinearLayout>
</HorizontalScrollView>
Happy coding!!
This question already has answers here:
How to customized the ListView height in android?
(4 answers)
Closed 5 years ago.
I am a beginner to android. I want to display a customized list view which contains a number. I customized my List item height size(android:layout_height="50dp"). But when I run the app it display the size largely which am not given. I don't know how to fix this problem. Could anyone help me?
activity_topic_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.yuvi.secrectsforhappylife.TopicList">
<ListView
android:id="#+id/topiclist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
titledesign.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/storylist">
<TextView
android:id="#+id/topictitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/title"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#android:color/background_light" />
</RelativeLayout>
TopicList.java
public class TopicList extends AppCompatActivity {
String topic\[\]={"one","two","three","four","five","six","seven","eight","nine","ten"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_topic_list);
ListView listView=(ListView)findViewById(R.id.topiclist);
CustomAdapter customAdapter=new CustomAdapter();
listView.setAdapter(customAdapter);
}
class CustomAdapter extends BaseAdapter
{
#Override
public int getCount() {
return topic.length;
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView=getLayoutInflater().inflate(R.layout.titledesign,null);
TextView title=(TextView)convertView.findViewById(R.id.topictitle);
title.setText(topic\[position\]);
return convertView;
}
}
}
Try below code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/storylist">
and make changes in your listview also like below
<ListView
android:id="#+id/topiclist"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
I want to make custom calendar, and for this I'm using a GridView (with 12 cells for months) with embedded GridViews for every month (showing days of months). I did very simple layout and code just to check how it looks. The problem is that I get 12 cells, but each of them shows only 1 row of inner grid (of month). So it shows like "0 1 2 3 4 5 6" for every cell of 12 (months).
First, it was worse - it was showing just single row of outer grid with single rows of inner grids. After some experimenting, I solved this problem: the issue was with that my main activity had root element of some special class (this was auto-generated by Android studio), I have changed it to LinearLayout and it started showing all cells of outer grid, but still just 1 row of the inner. First, my inner layouts were wrapped in RelativeLayout, I changed them all to LinearLayout hoping this will fix it - but there is no change. I also experimented a bit with widths and heights with no luck, and I have no idea what to try next.
Here are my layouts:
activity_main
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/calendar_year"></include>
</LinearLayout>
calendar_year (outer grid)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<GridView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/grid_year"
android:numColumns="3"
android:gravity="center"
android:stretchMode="columnWidth" />
</LinearLayout>
calendar_month (inner grid)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<GridView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/grid_month"
android:numColumns="7"
android:gravity="center"
android:stretchMode="columnWidth" />
</LinearLayout>
calendar_day (cell content)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/text_day"
android:textColor="#android:color/black" />
</LinearLayout>
onCreate of MainActivity.java:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
((GridView) this.findViewById(R.id.grid_year)).setAdapter(new YearGridAdapter(getApplicationContext()));
}
Outer grid's adapter:
public class YearGridAdapter extends BaseAdapter {
public YearGridAdapter(Context context) {
this.context = context;
}
#Override
public int getCount() {
return 12;
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.calendar_month, parent, false);
}
GridView monthView = (GridView) convertView.findViewById(R.id.grid_month);
monthView.setAdapter(new MonthGridAdapter(context));
return convertView;
}
private Context context;
}
Inner grid's adapter:
public class MonthGridAdapter extends BaseAdapter {
public MonthGridAdapter(Context context) {
this.context = context;
}
#Override
public int getCount() {
return 30;
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.calendar_day, parent, false);
}
((TextView) convertView.findViewById(R.id.text_day)).setText(Integer.toString(position));
return convertView;
}
private Context context;
}
This is probably caused by having GridView inside of GridView. Since both layouts are scrollable this causes a lot of problems. You can see on this link Arun Antoney's answer which may solve your problem
I tried to use a ListFragment with a custom layout: Simple static headline, below the ListContent given with the SimpleCursorAdapter. The list itself also has a custom layout. The SimpleCursorAdapter works (Query is fine, Custom Layout for List works). As long as I do not use custom layout for the Fragment itself, everything works fine.
If I add the layout for the Fragment, only the headline (Textview) works, the list keeps empty.
Custom Layout for the List:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" >
</TextView>
<TextView
android:id="#+id/value"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_gravity="right"
android:textSize="20sp" >
</TextView>
Custom Layout for the Fragment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/last_update"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<TextView android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:text="No data">
</TextView>
I commented some stuff out - it was worth a try because i read that it helped - for me it was not helping.
Last bot not least the Code of the Fragment:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.viewfragment, container, false);
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
TableDataGateway tableGate = new TableDataGateway(getActivity());
tableGate.UpdateUIRecords();
TextView tv = (TextView) getView().findViewById(R.id.last_update);
tv.setText(tableGate.getLastUpdateDate());
Cursor cursor = tableGate.selectUIRecords();
dBadapter = new SimpleCursorAdapter(getActivity(), R.layout.viewlayout, cursor, new String[] { DB_COL_GUI_LABEL, DB_COL_LAST_KNOWN_VALUE }, new int[] { R.id.label, R.id.value }, 0);
super.setListAdapter(dBadapter);
}
Question is: Why is the ListAdapter not connecting with the fragment layout?
Regards
Flizz
CLARIFICATION OF THE PROBLEM
I have a similar problem like Android + ListFragment with a custom view hierarchy
But i do not have stacked the content over each other, i only see the TextView content in the top corner of the screen and below where the list should be is just a white background.
I was pretty sure to have done anything as Google told to do (http://developer.android.com/reference/android/app/ListFragment.html keyword Screen Layout)
Update:
I am unsure whether i have to change my main_activity.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
I have not considered the fragment in there, do not know whether this is needed. Yesterday i tried a few functions to understand my problem in detail. I used getView().isShown() and get the return FALSE - this seems wrong to my, but I have no clue what is wrong here ...
Your ListView id must be #android:id/list in a ListFragment.
Maybe you should also replace super.setListAdapter to just setListAdapter.
Hey Here is a snippet of correct usage of CustomAdapter:
private class MyCustomAdapter extends BaseAdapter {
private ArrayList<String> mData = new ArrayList<String>();
private LayoutInflater mInflater;
public MyCustomAdapter() {
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void addItem(final String item) {
mData.add(item);
notifyDataSetChanged();
}
#Override
public int getItemViewType(int position) {
if(position < LIST_ITEM_TYPE_1_COUNT)
return LIST_ITEM_TYPE_1;
else
return LIST_ITEM_TYPE_2;
}
#Override
public int getViewTypeCount() {
return LIST_ITEM_TYPE_COUNT;
}
#Override
public int getCount() {
return mData.size();
}
#Override
public String getItem(int position) {
return mData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
int type = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
switch(type) {
case LIST_ITEM_TYPE_1:
convertView = mInflater.inflate(R.layout.list_item_type1, null);
holder.textView = (TextView)convertView.findViewById(R.id.list_item_type1_text_view);
break;
case LIST_ITEM_TYPE_2:
convertView = mInflater.inflate(R.layout.list_item_type2, null);
holder.textView = (TextView)convertView.findViewById(R.id.list_item_type2_button);
break;
}
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
holder.textView.setText(mData.get(position));
return convertView;
}
}
public static class ViewHolder {
public TextView textView;
}
}
After reviewing
Blank ListView with SimpleCursorAdapter
http://developer.android.com/samples/CustomChoiceList/src/com.example.android.customchoicelist/MainActivity.html
http://developer.android.com/samples/CustomChoiceList/res/layout/sample_main.html
i found the solution - everything is right so far. I just messed up the layout file:
Both contents ListView as TextView had the value "match_parent" - so there was not enough layout room for the other component. The component which comes first in the layout file overwrites everything else.
I adjusted the layout file to this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
</ListView>
<TextView android:id="#android:id/empty"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#FF0000"
android:text="No data">
</TextView>
<TextView
android:id="#+id/last_update"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>
</LinearLayout>
and everything works fine. Do NOT use the fragment layout for the activity - it should have its own layout, else it will lead to errors.
Thanks everybody for helping.
Rgds
Flizz
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...