CheckBox click in ListView - android

I have a listview with some text and a checkbox. I can click the checkbox, and the check changes, but when I try to listen for the check being changed, or the click, the listener never triggers.
I have the listview in an Activity (not a ListActivity)
schedule.xml layout:
<?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"
android:id="#+id/schedulerLayout">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:paddingBottom="10dp">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/currentHours"
android:textSize="50dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50dp"
android:text=":"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/currentMinutes"
android:textSize="50dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<!--vertical filler for am/pm display -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ampm"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/currentDayOfWeek"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/currentDate"/>
</LinearLayout>
</LinearLayout>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/scheduleButton"
android:text="#string/newSchedule"/>
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#FFFFFFFF"/>
<ListView
android:id="#+id/scheduler_list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
schedulerow.xml:
<?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:layout_alignParentLeft="true"
android:layout_alignParentTop="true">
<TextView
android:id="#+id/scheduleListTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:text="Title"/>
<TextView
android:id="#+id/scheduleListDays"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/scheduleListTitle"
android:text="Days"/>
<TextView
android:id="#+id/scheduleListMonths"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/scheduleListDays"
android:text="Months"/>
<View
android:id="#+id/schedulerSeparator"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="#FFFFFFFF"
android:layout_below="#id/scheduleListMonths"/>
<CheckBox
android:id="#+id/scheduleCheckBox"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="true"
android:layout_above="#id/schedulerSeparator"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
<TextView
android:id="#+id/scheduleListTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/scheduleCheckBox"
android:text="Time"/>
</RelativeLayout>
I'm filling in the data like this:
SimpleAdapter adapter = new SimpleAdapter(this,
data,
R.layout.schedulerow,
new String[] {"Title","Time","Day", "Month"},
new int[] { R.id.scheduleListTitle, R.id.scheduleListTime,R.id.scheduleListDays, R.id.scheduleListMonths});
listView.setAdapter(adapter);
If I try to add a listener to the checkbox, it does nothing. Any suggestions? I've looked through a TON of sample code and similar questions, and none of it seems to work.

One solution is to forget the list item click listener and use another listener for the rest of the item other than the checkbox.. In item layout xml, put the other views in single layout and set the click listener on this and set the check listener on checkbox as usual. Both will work without issues. Dont use the list item click listener.
class MySimpleAdapter extends SimpleAdapter {
...
#Override
void getView(.....) {
View view = super.getView(.....);
view.findViewById(R.id.checkboxid).setOnCheckChangedListner(checklistener);
view.findViewById(R.id.restOfitemview).setOnClickListner(clickListner);
return view;
}
}
Define the two listeners and set as shown above.
Edit : First try your method(blocking focus on checkbox) with the MySimpleAdapter setting only the checkchangelistener.. If that does not work then use above solution of dividing the item layout.

Related

OnListItemClick is not getting invoked when I call ViewPager.setPageTransformer

I have an activity that contains ViewPager to display different fragments when swipe.
Each fragment has a ListView in it, and each list view item perform some action when get clicked (let say shows Toast). I set OnItemClickListener on ListView to achieve it.
Everything works fine, But when I set page transform by calling setPageTransform() on ViewPager then list item click stops working.
How can I fix it?
Check the code below.
list_item_lessons.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp"
android:clickable="false"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:focusableInTouchMode="false">
<ImageView
android:id="#+id/list_item_image"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_weight="0"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
tools:src="#drawable/people"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false">
<TextView
android:id="#+id/list_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="bottom"
android:maxLines="1"
android:ellipsize="end"
android:textStyle="normal"
android:textSize="21sp"
android:textColor="#212121"
android:inputType="textCapSentences"
tools:text="ਐਤਵਾਰ"/>
<TextView
android:id="#+id/list_item_sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="top"
android:textColor="#757575"
android:textSize="16sp"
tools:text="alphabets" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"
android:src="#drawable/general_arrow_right"
android:alpha=".5"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"/>
Code that set page transformer inside MainActivity.java
// Set transformation for view pager, Getting values from preferences
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
String displayPref = sharedPref.getString(SettingsFragment.KEY_PREF_TRANSFORMATION, "");
viewPager.setPageTransformer(true, Utils.getPageTransformer(this, displayPref));

EditText can't edit in android ListView

Currently working with listview which contains edittext in each row.
The row item xml is below
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/result_solution_list_row_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/demo_product_background"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/artist_name_textview"
android:layout_width="#dimen/twohundred"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/home_dark_blue"
android:textSize="#dimen/list_text_size"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/contentLinearLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_weight="1"
android:descendantFocusability="afterDescendants"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="#+id/add_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="2dp"
android:textColor="#color/home_dark_blue"
android:textSize="#dimen/list_text_size"
android:textStyle="bold" />
<ImageView
android:id="#+id/img_camera"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_margin="2dp"
android:background="#drawable/ic_pre_camera"
android:contentDescription="#string/app_name" />
<ImageView
android:id="#+id/drag_handle"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center_vertical"
android:layout_margin="2dp"
android:background="#drawable/drag_icon"
android:contentDescription="#string/app_name" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/cus_container" >
</LinearLayout>
In this xml, LinearLayout - contentLinearLayout can be inflated a view dynamically.
The inflating view (xml) contains the EditText views.
The following is the inflated xml .
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingLeft="#dimen/five"
android:paddingRight="#dimen/five"
>
<TextView
android:id="#+id/artist_name_textview"
android:layout_width="#dimen/hundreadfifty"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/home_dark_blue" />
<LinearLayout
android:layout_width="#dimen/home_hundred"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/home_five"
android:layout_marginRight="#dimen/home_five"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/txt_name_quan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:singleLine="true"
android:text="QUANTITY"
android:textSize="#dimen/list_text_size"
android:textColor="#color/home_dark_blue" />
<EditText
android:id="#+id/txt_quan"
android:layout_width="#dimen/home_eighty"
android:layout_height="match_parent"
android:background="#drawable/edt_blue_background"
android:inputType="numberDecimal"
android:singleLine="true"
android:textColor="#color/home_dark_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="#dimen/nav_drawer_uf_image_width"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/txt_name_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:singleLine="true"
android:text="PRICE"
android:textStyle="bold"
android:textSize="#dimen/list_text_size"
android:textColor="#color/home_dark_blue" />
<EditText
android:id="#+id/txt_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/edt_blue_background"
android:inputType="numberDecimal"
android:singleLine="true"
android:textColor="#color/home_dark_blue" />
</LinearLayout>
My problem is , I want both events. 1. ListView's OnItemClickListener 2. EditText should be editable.
I have tried the solutions posted in below links
Trying to catch a click on android ListView item: android:descendantFocusability="blocksDescendants" not working
Android EditText in ListView - keyboard
Focusable EditText inside ListView
http://androidtechnicalblog.blogspot.in/2014/04/quick-trick-of-week-edittext-inside.html
Most of the solutions stressed on android:descendantFocusability attribute.I have tried with different values and set to the listview and listview's root layout alone.
Still the EditTexts are not editable.
Any solutions ?
I have done this with the Imageview earlier.
At that time i put the click listner of Imageview at the Adapter.
I am not sure but may be this will help you.
set this at your adapter
viewHolder.txt_price.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// Your Code
}
});
your ListView click event
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// your code
}
});
Not Sure might be help You. Good Luck

How to convert a GridView to an ExpandableListView

I have used GridView in my project and with that I included the ViewHolder.
Now, the customer wants to show the data using an ExpandableListView for the fact that he wants to only show the header and when the user clicks on the header, it shows the child below it.
Having no prior experience, I want to know if it possible to change from GridView to ExpandableListView easily in the code.
Note that I have also included text search on the Grid. Will that still be available if I switch to ExpandableListView?
If the above is possible, can anyone help how I could achieve it.
The Grid row xml is as follows
<?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="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dip"
android:paddingRight="4dip">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0.8">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:typeface="sans"
android:textSize="13sp"
android:textStyle="bold"
android:id="#+id/placeName"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#88FFFFFF"
android:typeface="sans"
android:textSize="13sp"
android:textStyle="bold"
android:id="#+id/theme"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:id="#+id/Title"/>
<TextView
android:id="#+id/Details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
/>
<TextView
android:id="#+id/scheduleDays"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_gravity="bottom"
android:layout_marginRight="5dip"
android:layout_marginTop="7dip"
android:text="Family, Friends, Relatives, Grand-Parents"
android:textStyle="bold"/>
<TextView
android:id="#+id/Date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:layout_gravity="right"
android:layout_marginRight="5dip"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/rightLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical"
android:minWidth="60dp"
android:layout_weight="0.2">
<ImageView
android:id="#+id/starButton"
android:layout_width="40dp"
android:layout_gravity="right"
android:layout_marginRight="5dip"
android:layout_height="40dp"
android:background="#00FFFFFF"
android:src="#drawable/Favourite"/>
<ImageView
android:id="#+id/showMeButton"
android:layout_width="40dp"
android:layout_gravity="right"
android:layout_marginRight="15dip"
android:src="#drawable/showMe"/>
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/separator"
android:layout_marginTop="5dip"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#33000000" />
</LinearLayout>
With ListView, I want to show PlaceName, Favourite Button and ShowMe Button as the headers and the rest as the child.
You can integrate the Expandable ListView in an Layout, like LinearLayout.
For this Change the Layout type in the layout.xml of your activity
To send the Data to the ListView you need to use an BaseExpandableListAdapter that pulls the Content out of an Array or a Database.
Example for the layout.xml
<LinearLayout .... >
<ExpandableListView
.... >
</ExpandableListView>
</LinearLayout>
can you show your xml file. well can be achieve is many ways.
like change your layout container from grid layout to linear layout
as in your adapter
and set your View in onCreate
recycler.setHasFixedSize(true);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recycler.setLayoutManager(layoutManager);
adapter = new Adapter(getActivity());
recycler.setAdapter(adapter);

Listview listselector not working

I am creating some views in my xml file, xml file contaings list-view.
In that list-view I have list selector attribute and i defined drawable
image for selector.
My xml file follows like this:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="#+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.naaima.vovinet.activity.VideoNativePlayer
android:layout_marginLeft="50dip"
android:layout_width="800dip"
android:layout_marginRight="30dip"
android:id="#+id/video_view"
android:layout_height="600dip"
android:layout_marginTop="50dip">
</com.naaima.vovinet.activity.VideoNativePlayer>
<ImageView android:src="#drawable/icon"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="#+id/imageView1"/>
<ImageView android:src="#drawable/icon"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:id="#+id/imageView2"/>
<LinearLayout android:id="#+id/linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView_channelno"
android:layout_width="130dip"
android:hint="_ _ _"
android:layout_marginLeft="1050dip"
android:layout_marginTop="20dip"
android:background="#drawable/sample"
android:gravity="center"
android:textSize="25dip"
android:visibility="gone"
android:layout_height="80dip"/>
</LinearLayout>
<FrameLayout android:id="#+id/frameLayout2"
android:layout_width="1100dip"
android:layout_height="wrap_content"
android:background="#drawable/bg1"
android:layout_gravity="bottom"
android:layout_marginLeft="100dip"
android:layout_marginBottom="15dip">
<RelativeLayout android:id="#+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ProgressBar style="?android:attr/progressBarStyleHorizontal"
android:layout_width="730dip"
android:layout_height="wrap_content"
android:id="#+id/progressBar"
android:layout_marginTop="30dip"
android:background="#drawable/progress_bar_bg"
android:layout_marginLeft="180dip"/>
<TextView android:id="#+id/textView_date"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="#+id/progressBar"
android:layout_marginTop="30dip"
android:layout_marginLeft="50dip"/>
<TextView android:id="#+id/textView_time"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#+id/textView_date"
android:layout_marginTop="3dip"
android:layout_toRightOf="#+id/list"
android:layout_marginLeft="57dip"
/>
<TextView
android:id="#+id/textView_location"
android:text="Hyderabad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_time"
android:layout_marginTop="10dip"
android:layout_marginRight="10dip"
android:layout_toRightOf="#+id/imageView_temp"
/>
<TextView
android:id="#+id/textView_temp"
android:text="35 Degrees"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_location"
android:layout_marginRight="10dip"
android:layout_marginTop="5dip"
android:layout_toRightOf="#+id/imageView_temp"
/>
<ImageView android:id="#+id/imageView_temp"
android:src="#drawable/temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView_time"
android:layout_toRightOf="#+id/list"
android:layout_marginLeft="20dip"/>
<ImageView android:id="#+id/imageView_logo"
android:src="#drawable/zee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dip"
android:layout_marginLeft="50dip"/>
<ImageView android:id="#+id/imageView_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_left_gray"
android:layout_marginTop="110dip"
android:layout_marginLeft="23dip"/>
<TextView android:id="#+id/txt_channelName"
android:text="M-Tunes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="110dip"
android:layout_marginLeft="50dip"/>
<ImageView android:id="#+id/imageView_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_right_gray"
android:layout_marginTop="110dip"
android:layout_marginLeft="150dip"/>
<ListView android:id="#+id/list"
android:layout_width="690dip"
android:layout_height="125dip"
android:layout_below="#+id/progressBar"
android:layout_marginLeft="220dip"
android:listSelector="#drawable/highlight_bar"/>
<ImageView android:id="#+id/imageView_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/arrow_up_gray"
android:layout_below="#+id/progressBar"
android:layout_marginTop="5dip"
android:layout_marginLeft="180dip"/>
</RelativeLayout>
</FrameLayout>
</FrameLayout>`
Row.xml
<?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"
>
<TextView android:text="TextView"
android:id="#+id/textView_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
And java code is like following
ListView lv = (ListView) findViewById(R.id.list);
String[] values = new String[] { "Now:Harry Potter and Deathly Hellows", "Lord of the Rings:Two Towers", "Lord of the Rings:Return of King",
"rd of the Rings:Honneypot solo Dance"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.row,R.id.textView_list, values);
lv.setAdapter(adapter);
lv.setSelector(R.drawable.highlight_bar);
lv.setDivider(null);
If I am executing only listview with row xml code list selector working fine.
If I am pressing up and down arrows it's working fine. But I am integrating
listview with above code it's not working and if I am pressing up and arrows
in keyboard no use (focusing not going to listview side).
Just to add on to Jason's above response. I recently ran into this issue and Jason's answer was spot on, except I needed to call requestFocusFromTouch() on my listView to make it work in response to touch obviously. requestFocus() was not helpful in my scenario but requestFocusFromTouch() was. Hopefully that helps someone out there.
Have you tried calling "requestFocus()" on the listView in your code after setting android:focusable="true" in the xml? From the View docs:
"Call this to try to give focus to a specific view or to one of its descendants. A view will not actually take focus if it is not focusable (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode. See also focusSearch(int), which is what you call to say that you have focus, and you want your parent to look for the next one. This is equivalent to calling requestFocus(int, Rect) with arguments FOCUS_DOWN and null."

problem to make scroll able,set scroll for whole layout android

had make layout for showing the content in listview and a button below on list view for displaying more information on list view ,so first i am showing only 4 rows in list view and when i next time click on button 4 rows again added in list so now my button goes down in screen so how to make whole layout scroll able so that i can go to button via scrolling my layout is..
listplacehold.xml is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#1A77BD"
>
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawSelectorOnTop="false" />
<View
android:id="#+id/horizontolline"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_below="#id/android:list"
android:background="#000000"
/>
<Button
android:text="Load More..."
android:textColor="#color/white"
android:id="#+id/keywordsearchbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/horizontolline"
android:drawableLeft="#drawable/load_more_off"
android:gravity="left|center_vertical"
android:background="#1A77BD"
/>
</RelativeLayout>
and for list item layout is: listitem.xml is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView android:id="#+id/img"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<!-- Location where barrio items will be displayed -->
<TextView
android:id="#+id/reportid"
android:layout_marginLeft="70dip"
android:text="reporet id"
android:textColor="#color/white"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<TextView android:id="#+id/status"
android:textColor="#color/white"
android:text="status"
android:layout_marginTop="40dip"
android:layout_marginLeft="200dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="#+id/title"
android:text="title"
android:layout_marginLeft="150dip"
android:textColor="#color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/date"
android:text="dateeeeeee"
android:layout_marginLeft="70dip"
android:layout_marginTop="40dip"
android:textColor="#color/white"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
items are dynamically loadein list view when button click
i think that scroll will be set on above xml means on "listplacehold.xml" but how?,when i am doing it is set to for half screen,means it is not displaying in whole view... Thanks for help in advance.
don't use the ScrollView with the combination of the ListView. Instead make your layout like this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#1A77BD" >
<Button
android:id="#+id/lodmore"
android:text="Load More..."
android:textColor="#color/white"
android:id="#+id/keywordsearchbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true""
android:drawableLeft="#drawable/load_more_off"
android:gravity="left|center_vertical"
android:background="#1A77BD"/>
<View
android:id="#+id/horizontolline"
android:layout_width="fill_parent"
android:layout_height="1dip"
android:layout_above="#id/loadmore"
android:background="#000000"/>
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_alignParentTop="true"
android:layout_above="#id/horizontolline/>
</RelativeLayout>
put scrollview over your root layout and remember only one layout node is allowed under scrollview.....
refer this doc:
http://developer.android.com/reference/android/widget/ScrollView.html

Categories

Resources