Tag: listview

Last Item on Listview is cut off

So in my Android app I have where the main activity has tabs and in each tab there is a fragment containing a listview. But for some reason the last item in the listview always gets cut off. I have looked around for solutions but I havent found any yet. Any suggestions? Main Activity layout […]

ListView doesnt fire setOnLongClickListener, only setOnItemClickListener

I’d like to have both type of clicks on a listView – onClick and LongClick. I’ve implemented it like this: this.listViewSub = (ListView) this.findViewById(R.id.listsub); this.listViewSub.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView parent, final View view, final int position, final long id) { … } }); // listen to long click – to share texts […]

Android: Finding ListView's item rendered height

Is there any way of finding the height of a ListView’s item currently being shown in the list without setting it yourself in the layout xml files? I’ve tried View listItem = listAdapter.getView(currentIndex, null, listView); listItem.measure(MeasureSpec.EXACTLY, MeasureSpec.UNSPECIFIED); int itemHeight = listItem.getMeasuredHeight(); and while it worked initially, it decided to throw a Null Pointer Exception during […]

Android action bar batch selection for versions prior to 3.0

I have a ListView for which I want to enable batch selection. For android 3.0 and above I’ve added a modal multi choice to the ListView and set the multi choice mode listener. How can I do the same for android versions prior to 3.0 (with or without a third party library) ? I’ve looked […]

Updating textview on activity once data in adapter class is changed

I am having textview txtQuantity in my dashboard activity. I wrote separate class for custom adapter which will contain sold products. protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dashboard); list = (ListView) findViewById(R.id.listSoldItems); txtAmount = (TextView) findViewById(R.id.txtAmount); txtItems = (TextView) findViewById(R.id.txtItems); // init listview adapter = new Sold_item_adaptor(Dashboard.this, soldItemsList); list.setAdapter(adapter); I can remove items from list […]

getting java.lang.ArrayIndexOutOfBoundsException in android

I am using pinned-section-listview from here and getting following error after scrolling, 07-31 17:52:46.640: E/InputEventReceiver(25288): Exception dispatching input event. 07-31 17:52:46.657: E/AndroidRuntime(25288): FATAL EXCEPTION: main 07-31 17:52:46.657: E/AndroidRuntime(25288): java.lang.ArrayIndexOutOfBoundsException: length=2; index=2 07-31 17:52:46.657: E/AndroidRuntime(25288): at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6916) 07-31 17:52:46.657: E/AndroidRuntime(25288): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5442) 07-31 17:52:46.657: E/AndroidRuntime(25288): at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3310) 07-31 17:52:46.657: E/AndroidRuntime(25288): at android.widget.AbsListView.onTouchEvent(AbsListView.java:3654) 07-31 17:52:46.657: E/AndroidRuntime(25288): at […]

The content of the adapter has changed but ListView did not receive a notification – With AsyncTask

I am using AsyncTask to set my items and stuff, in the postExecute i call a synchronized Method where i do this mAllResultsAdapter.setItems(mAllResultsItem); mAllResultsAdapter.notifyDataSetChanged(); mListView.invalidate(); mListView.requestLayout(); Most of the time if I dowload new data and update my listview/adapter it simply works, and pretty good to. But somehow it crashes sometime, can anyone assist me […]

listView onclick goes to a new activity

i have a listview and i would like to go to a new activity from every list item i press.this is my code.. public class DialogActivity extends Activity { private ListView lv1; private String lv_arr[]={“SuperLeague 2010-2011″,”Olympiakos on YouTube”,”Olympiakos Web Site”,”Find Karaiskaki on map”,”Reserve Tickets”}; /** Called when the activity is first created. */ @Override public […]

(Android)listview with multiple buttons, list item can't be clicked

I have list with two buttons on it. When I want to click a list item it doesn’t work, but my button is still clickable. How I can make all buttons include the entire list item to be clickable? List item: <TwoLineListItem xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:mode=”twoLine”> <Button android:id=”@+id/erase” android:layout_width=”40dip” android:layout_height=”40dip” android:focusable=”false” android:focusableInTouchMode=”false”/> <ImageButton android:id=”@+id/soundf” android:layout_width=”40dip” […]

Android get text of all checked checkboxes in listView

hello i have created a listview with checkboxes in it… but i dont know how to get the check box text which are selected.. here is the code of activity_main.xml <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/LinearLayout1″ android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:gravity=”top” android:orientation=”vertical” tools:context=”.MygamesActivity” > <ListView android:id=”@android:id/list” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:layout_marginTop=”20dp” /> </LinearLayout> another layout which has checkboxes to show in […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.