Menu
  • HOME
  • TAGS

Having problems while trying to implement a CheckBox in a custom todolist using a custom adapter?

android,listview,checkbox,android-listview

I think the following two things should help you in making the checkboxes clickable ->> Add android:descendantFocusability="blocksDescendants" in the parent ViewGroup of todo_list layout ->> Add android:clickable="true" in your todo_CheckBox view's definition Once, you can start seeing the checkboxes clicking on the screen, as user370305 rightly mentioned checks on the...

List view item touch feedback not applied to whole row

java,android,xml,android-fragments,android-listview

Change your ListView width to match parent. That way the list item will be a full row.

ListView & onItemClick - When click, open new activity [on hold]

java,android,listview,android-listview,onclicklistener

To start a new Activity you have to use intents : Intent intent = new Intent(this, MySecondActivity.class); You can add extras : intent.putExtra(EXTRA_MESSAGE, message); And to start the activity : startActivity(intent); Now if you wan to do it when you click on an item of your list you'll have to...

Android - How to put a item click in ListView with Hashmap and List

java,android,listview,android-listview

Sorry I didn't get back to you sooner but I was busy. Don't use a hashmap to store the Bitmaps. It's over complicating things. ArrayList<Bitmap> list2 = new ArrayList<>(); then change this line.. Bitmap Imageback = list2.get(position).get(R.id.index); to this Bitmap ImageBack = list2.get(position); The reason why what you wrote didn't...

Use async task to modify element in a contact listview

android,json,android-listview,android-asynctask

You are on the right track with: new JSONParse().execute(phoneNumber); Just make sure phoneNumber is a String. is this the correct way to get the phoneNumber send in the execute String phoneNumber = args[0]; Yes, that is the correct way. The first and only argument your AsyncTask accepts is phoneNumber and...

Attaching layout directly to listview bottom

android,android-layout,listview,android-listview

Okay so I used two different layouts that are identical. One for the footer (when the listview does not populate the entire screen) and one for the bottom view(when the listview is larger than the screen). Keep in mind that they are two different views but identical. That means you...

Remove space between app border and a List view

android,android-listview

The padding is due to the padding provided to RelativeLayout From your XML code remove padding by making you code look like <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" tools:context=".MainActivity"> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listView" android:layout_alignParentTop="true"...

Android's List View. Parameterized type in AdapterView.OnItemClickListener

java,android,android-listview,parameterized-types

As you might have seen if you try new AdapterView<SquirrelAdapter>.OnItemClickListener() compiler would say, The member type AdapterView<SquirrelAdapter>.OnItemClickListener cannot be qualified with a parameterized type, since it is static. What you are doing inside listView.setOnItemClickListener is to create an Anonymous class, for an interface OnItemClickListener inside abstract class AdapterView. Now, to...

ListView item is not clicking

java,android,listview,android-listview,listviewitem

If you want to click entire row, just implement OnClickListener. If you want to click entire row and links inside the row (which i thing this is what you want): You have to create a custom row item Create an interface Send that interface listener to the adapter Check if...

list view in fragments null pointer exception

java,android,android-fragments,android-listview,swiperefreshlayout

Your recent_list is null and you are referencing it outside the onCreateView inside your RecentsCardFragment, this is why the NullPointerException happenning. Move your recent_list declaration into your onCreateView method, like this: public class RecentsCardFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { ListView recentsList; private SwipeRefreshLayout refreshBooks; ArrayList<HashMap<String,String>> items = new ArrayList<>(); //private...

Android, Listview on Scroll Item position issue

android,android-listview,listviewitem,onscroll

Whenever loading the listview you need to consider all the scenario. What i mean was if you are setting text for textview using if condition you must write else condition and need to write action for that textview. If you don't consider else part then you got that issue. When...

custom ArrayAdapter ViewHolder : imageView changes for several items in Listview not for one only

android,listview,android-listview,imageview

ok i found a workaround by referencing the private LinkedList<Entity> entity; public AuthorsAdapter(Context context, LinkedList<Entity> entity) { super(context, 0, entity); this.entity = entity; } in the constructor then instead of doing like you said : .... else{ holder = (ViewHolder) convertView.getTag(); } if (!getItem(position).isImageResized()) { holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));...

Replace list in master activity with another list and remove old list from view

java,android,android-fragments,android-listview,android-listfragment

The main problem why the fragment is not showing upon poping the backstack is that you are trying to inflate that fragment in another fragments id which is this part of the code: transaction.replace(R.id.master_container, newFragment); You don't need a whole new activity just to host another fragment which you did...

Android List view buttons text color changing when scrolling top to bottom?

android,android-listview

If holder.b1 button text is changing then the reason is you are not handling your getView properly. I guess this returns some Integer id list.get(position).Rno So you need to store that id in some arraylist for example //Declare this outside of getView(). ArrayList<Integer> your_number = new ArrayList(); And in your...

Add scrollView and highlight on a Linear Layout in Android

android,android-layout,android-listview

I hope this will work for u : <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:id ="@+id/mainFilterLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <ImageView...

Is it possible to center a single item on a listview?

android,xml,listview,android-listview

You need to set the Gravity to CENTER programatically on that particular element to center it in your Adapter's getView() method. If you use the ViewHolder pattern, make sure you set the other ones to default; so you'll need an if/else statement.

Clicked Animation is gone after design with

android,listview,android-listview

A solution to my problem was found by creating in the @drawable folder: 1) "NOT Clicked" Background layout to the ListView item named not_clicked_layout.xml like: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="1.5dp" android:color="#000000" /> <solid android:color="@color/green"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="0dp" /> <corners android:radius="4dp"/> </shape> 2)...

Change ListView's ScrollBar/FastScroll color?

android,android-listview,material-design

Scrollbar thumb color is set to the android:colorAccent attribute in your app theme. You are sure that is set and is correct, right? Note that if you're using AppCompat, you will have to exclude the android: prefix from the attribute. You can find more information on available color attributes here....

Listview - list item selection and initial setting (custom made items)

android,android-layout,android-listview

Finally (with the help of a friend) I found all answers. The code works across many versions. This ends a long search, I hope this is of help for you! Answer 1: nice custom layout of your list items. Customshape and customshape_pressed. Change them, this is just an example. Answer...

ListView Adapter executing onclick methods on multiple rows simultaneously for a single click event

android,listview,android-listview,android-adapter

I got it working by using HashMap as SAM suggested. Here is what I did. in Adapter class HashMap<Long, String> map = new HashMap<Long, String>(); in getView()method of adapter if(post.postlikeflag==0){ map.put(post.postid, "like"); } else{ map.put(post.postid,"liked"); } if(map.get(post.postid).equals("like")) { holder.like.setBackgroundResource(R.drawable.like); } else { holder.like.setBackgroundResource(R.drawable.liked); } And in onclickListener of like button...

ScrollingViewBehavior for ListView

android,android-listview,android-support-library,android-recyclerview

The only solution to make it work now is to use this: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { listView.setNestedScrollingEnabled(true); } It will obviously only work on Lollipop....

Android ripple background color

android,android-activity,android-listview,navigation-drawer,rippledrawable

You can control the colour of the RippleDrawable by doing the following: RippleDrawable rippleDrawable = (RippleDrawable)view.getBackground(); // assumes bg is a RippleDrawable int[][] states = new int[][] { new int[] { android.R.attr.state_enabled} }; int[] colors = new int[] { Color.BLUE }; // sets the ripple color to blue ColorStateList colorStateList...

How Can I launch event when user touch during 2 second on listview?

android,android-listview

You need to use OnItemLongClickListener(), like this: lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); alert.setTitle("Service") .setMessage("Add to favorite?") //.setIcon(R.drawable.chile1) .setPositiveButton("Si", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new...

list view did not show any value in android studio

android,json,listview,android-listview

Exception is thrown here: String id = c.getString("idPatient"); There is no "idPatient" key in your JSON. Try to replace it with just "id"...

Navigation drawer listview position not refreshing

android,android-listview,navigation-drawer,baseadapter

You are always calling displayView() with the selected index position in the list of NavDrawerItems. In the case where the user is logged out, there are only 2 items in the list. When the user chooses "login", the index position is 1, not 5. You probably want to add one...

Adding objects to listview dynamically from other class in android

android,android-activity,android-listview

It is a simple change of declaring MyListAdapter in your MainActivity and instantiate it once in the populateListView, public class MainActivity extends Activity { private List<Assignment> allDeliveries= new ArrayList<Assignment>(); MyListAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); populateDeliveryList(); populateListView(); registerClickCallBack(); final MySQLiteHelper db = new MySQLiteHelper(this);...

Null Pointer Exception while setting value of TextView in an Array Adapter class - Android

java,android,listview,android-listview,nullpointerexception

You already know where the problem is! tv.setText(question.toString()+""); is causing the NPE that means the TextView tv is null. And that means that the line TextView tv = (TextView) view.findViewById(R.id.question_list_item_string); is not able to find the TextView. Check the question_list_item_string id and make sure it matches the id in your...

android listview ArrayAdapter string cannot be cast to HolderView

java,android,listview,android-listview,android-arrayadapter

inflate() returns the root layout of your XML view hierarchy. Assuming the root view has the id rowbackground, this line holder.rw.setTag(menuLinkList.get(position).getId()); overwrites the viewholder tag with a String and recycling the view won't work. You can store additional data such as an id in a view holder field, no need...

Having problems to implement a setOnClickListener - Fragment

android,android-fragments,android-listview

The error message says: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead The OnClickListener is meant for click events on whole views. In an AdapterView, you usually want to register click events for each item separately. For this you need to use OnItemClickListener....

How to constant the index for Search in AndroidListViewWithSearch

android,android-listview,android-search

Try to change your listener // listening to single list item on click lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // getting values from selected ListItem vo value je sprava String prodname = ((TextView) view.findViewById(R.id.product_name)).getText().toString(); if( prodname.equals("Apple") { //code specific to first list...

An activity with two listviews in android

android,android-layout,android-activity,layout,android-listview

Your problem is with your RelativeLayout under your ScrollView. Try replacing it with a vertical LinearLayout and give its 2 child LinearLayout a weight of 1 like this: <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" > <LinearLayout android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/ll" android:layout_width="fill_parent"...

Android seekbar update text view in list view

android,android-listview,android-seekbar

Create a custom list adapter with BaseAdapter or ArrayAdapter. Attach adapter to ListView In getView() method of adapter get the reference of seekbar and set the listener to seekbar like this: final TextView text=convertView.findViewById(R.id.textview); final SeekBar seekbar=(SeekBar) convertView.findViewById(R.id.seekBar1); sk.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated...

Update ListView footer

android,android-listview,android-view,android-view-invalidate

The behavior is expected only. Calling invalidate() of any view will just re-draw the content what is there already, it will not update unless the change is in the canvas. When you change the language, the footerView is not notified, so that it can change the content. So when you...

adapter.notifyDataSetChanged() not working when I update ArrayList

android,android-listview

I have one way Create refresh method in your Adapter like public void refresh(ArrayList<Aviso> itemsw) { this.items = itemsw; notifyDataSetChanged(); } Now you just called this method from your Activity Aviso aviso = new Aviso(); aviso.setTitle("MMMMMMMMMMMMMMMMMMMMMM"); aviso.setDescription("Deskribapena"); aviso.setPubDate("Wed, 19 Mar 2016 12:40:00 GMT"); aviso.setDcDate("2016-03-19T12:40:00Z"); avisosList.add(aviso); adapter.refresh(avisosList); EDIT: To add the...

Get adapter from OnActivityCreate()

java,android,android-fragments,android-listview,notifydatasetchanged

Just make it visible for the entire Activity. ... MyClass { private MyArrayAdapter adapter; @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); String[] names = new String[] { "name1", "name1", "name1" }; String[] values = new String[] { "value1", "value2", "value3" }; adapter = new MyArrayAdapter(getActivity(), names, values); setListAdapter(adapter); } //...

Listview onItemClickListener obtaining data

android,arrays,listview,android-listview,parse.com

If i understood, this is one way of do this: SharedPreferences settings = getSharedPreferences("NotificationIDs", Context.MODE_PRIVATE); Set<String> myStrings = settings.getStringSet("myStrings", new HashSet<String>()); List<ParseObject> users = new ArrayList<>(); final ListView idList; idList = (ListView) findViewById(android.R.id.list); final ArrayAdapter<String> str = new ArrayAdapter<>(getBaseContext(), android.R.layout.simple_list_item_1, new ArrayList<String>()); idList.setAdapter(str);...

AddView() to Expandable ListView

android,listview,android-listview,xamarin

So the workaround was(for me),to generate post condition and put different layouts : if(!SpecificLayout) { var inflater = _context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; view = inflater.Inflate(Resource.Layout.SpecificLayout, null); } else { var inflater = _context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater; view = inflater.Inflate(Resource.Layout.AnotherLayout, null); } ...

List shows as not null but ArrayAdapter throws NullPointerException

java,android,android-listview,nullpointerexception,android-arrayadapter

Your context is null. Use MainActivity.this for a context in an anon inner class of your activity.

How to get Images from Internet and past it in a ListView?

android,json,android-listview,android-arrayadapter,listadapter

Volley Library makes this work quite easy and handles all other related tasks itself. You can use ImageLoader or NetworkImageView.Follow the link for how to acheive it: https://developer.android.com/training/volley/request.html

Can't center Navigation Drawer items vertically

android,android-listview,navigation-drawer

Change your drawer item to this: <?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="horizontal" > <TextView android:id="@+id/frag1_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="10dp" android:textAppearance="?android:attr/textAppearanceLarge" /> </LinearLayout> then try, it is working for...

How to set data to custom row TextView in ListView

android,android-listview,android-adapter

You'll need to improve your ArrayAdapter. Currently you're not setting the data to the TextView. Try the following, I didn't test it but it should work. public class CategoryAdapter extends ArrayAdapter { private LayoutInflater inflater; public CategoryAdapter(Activity activity, ArrayList<Category> items){ super(activity, R.layout.row_category, items); inflater = activity.getWindow().getLayoutInflater(); } @Override public View...

Can't get the right view in a list by view.getTag()

android,listview,android-listview,view

this line inside your click listener is the issue: viewHolder = (ViewHolder) view.getTag(); the view received during click is the actual clicked view, meaning on the call onClick(View v) for the case R.id.edit_imagebutton the View v is the ImageButton editIB . So when you ask for the tag of it,...

Listview getView method not getting called

android,listview,android-listview,baseadapter,swiperefreshlayout

In onCreateView(), it is not returning the root view, it is returning null because the class member v is null initially and is not modified. The existing code, change FROM: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (v == null) { View v = inflater... }...

Android ListView adding too many items

android,for-loop,android-listview,android-edittext,android-linearlayout

The problem is that the ArrayAdapter will call getView() each time the row becomes visible. If the row has been set up previously, it will pass in the previously set up View in the convertView parameter. See here for details. From the documentation for convertView: The old view to reuse,...

Failed to retrieve data from a database, to complete a listview

android,android-activity,android-listview,android-database

Since you have public Lugar(String nombre, String direccion, double longitud, double latitud, double altura, TipoLugar tipo, int telefono, String url, String comentario, int valoracion) in your Lugar class, default constructor won't be available. Either you need to always use above constructor or define an empty constructor public Lugar() { }...

Android toolbar context menu for listview items

android,android-listview,menu,contextmenu,android-toolbar

Check this official android guide. EDIT: Using the contextual action mode For views that provide contextual actions, you should usually invoke the contextual action mode upon one of two events (or both): The user performs a long-click on the view. The user selects a checkbox or similar UI component within...

Change row color of a ListView with Cursoradapter and bindView

android,listview,android-listview,android-cursoradapter

Instead of creating a new Adapter every time your list got clicked (which caused the list to scroll back to top) you could utilize a SparseBooleanArray to keep track on what items is currently in selection. In your adapter: public class YourAdapter extends CursorAdapter { // Initialize the array SparseBooleanArray...

Layout Items not appearing in Listview

android,android-layout,listview,android-fragments,android-listview

listItem = layoutInflater.inflate(R.layout.news_item_layout, parent, false); You're currently setting your row's root elements to null, which will cause your layout_xx attributes to be ignored http://possiblemobile.com/2013/05/layout-inflation-as-intended/...

When putting listview inside a RelativeLayout it always looking for R.id.list

android,android-layout,listview,android-listview

The reason it is asking for android:id="@id/android:list" is because you are extending your Fragment with ListFragment, read the documentation here ListFragment Documentation you can simply extend your Fragment class with Fragment instead of ListFragment....

setOnClickListener not firing with custom adapter and custom ListView

java,android,listview,android-listview

Thanks to Daniel Nugent's suggestion I got it working. Removing the convertView.setOnClickListener() is part of the answer. I think it was blocking the other listeners in the HotelOverviewFragment. My next mistake was that I used setOnClickListener on a ListView for testing. setOnClickListener should be used for buttons not ListViews. So...

How do I permanently change the background color of a row in a Listview?

android,xml,android-listview

What you have to do is to make a Custom ListView with your own row_layout.xml file, a CustomListViewObject that has a boolean to check if the element is clicked or not, and lastly, a CustomListView to check if the row element is selected or not. Your row layout row_layout.xml: <?xml...

Change text color of android.R.layout.simple_list_item_multiple_choice

android,android-listview,multichoiceitems

Just make custom layout - simple_list_item_multiple_choice.xml like this - <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:paddingLeft="6dip" android:paddingRight="6dip" android:textColor="#FF0000"...

Loading listview using SharedPreferences throwing OutofMemoryError

android,listview,android-listview,sharedpreferences

count = pred.getInt("countd",count); if(count > 0){ for(int i = 0; i < count; i++){ arrayCars.add(new Car(pred.getString("Value["+i+"]", ""),"green",3455)); count++; } } In the above code you are increasing count by 1 each time so it never ends loop will repeat untill it throw exception. To avoid delete that count++; Hope this...

CardView and RecyclerView divider behaviour

android,android-layout,android-listview,android-cardview,android-recyclerview

The spaces you can see are compat paddings and they're visible only on pre-Lollipop devices (or everywhere if you set card_view:cardUseCompatPadding="true"). You can find values here (CardView's doc). Before L, CardView adds padding to its content and draws shadows to that area. This padding amount is equal to maxCardElevation +...

Error when pressing an item in a listview

android,android-activity,android-listview,android-database

This exception, ClassCastException, says that you have done an invalid class casting. lugar.setPosicion((GeoPuntoAlt) new GeoPunto(cursor.getDouble(3), cursor.getDouble(4))); In this line, you have casted output of new GeoPunto(...) to GeoPuntoAlt. Make sure this casting is valid....

Delete Database and ListView in Android

android,listview,android-listview

Root cause here: Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 Your table in database is empty (as the result, the cursor is empty), but you are trying to get something in it. The solution is always check cursor.moveToFirst() before you query anything. if (cursor != null...

Animation on reordering ListView Item

android,listview,animation,android-listview,adapter

Thanks to the response of CommonsWare I used RecyclerView and it's much simpler animating the insertion and removal of items.

Implement 'Undo' Swipe to remove from listview android

android,listview,android-listview

Found a great library which does what I was looking to do!! https://github.com/timroes/SwipeToDismissUndoList...

ListView Footer causes ArrayIndexOutOfBoundsException

java,android,android-listview,indexoutofboundsexception,baseadapter

getViewTypeCount() is used to instantiate an array of convertViews, indexed by the returned value of getItemViewType(), and like every array, it is 0-based. For this reason your getItemViewType() can't return a value grater than or equal to the value of getViewTypeCount(). The only values possible with getViewTypeCount() == 2 are...

ListView adds empty view to root/parent instead of self?

android,android-listview,android-5.0-lollipop

Aren't the list items children of the ListView? Yes, when the ListView creates them via the associated ListAdapter. The empty view is not a list item. It is not a child of the ListView. It is simply another view. AdapterView toggles the visibility of itself and the empty view,...

Android custom listview display last item on first position

java,android,listview,android-listview

I think you'd better let the server do the sequencing,using "order by" in SQL selecting. If you do the sequencing in android app, once something changed in your database,or business logic improved,you have to rewrite your sequencing codes in app,and let all your users update there app.You can change the...

ListFragment appearing twice on phone

java,android,xml,android-listview,android-listfragment

Please move the logic to add fragment inside the if loop you have.

Position of items in listview is changing when I scroll the listview?

android,android-layout,android-listview

Remove the static specifiers of the ViewHolder Try replacing this private static class ViewHolder { private static TextView tv_Title, tv_Price, tv_SellingPrice, tv_ShippingCharge, tv_TotalPrice; private static ImageView iv_Cancel, iv_ProductImage; } with private static class ViewHolder { private TextView tv_Title, tv_Price, tv_SellingPrice, tv_ShippingCharge, tv_TotalPrice; private ImageView iv_Cancel, iv_ProductImage; } ...

Layout takes time to start

android,android-layout,android-listview

Please refer to this http://developer.android.com/training/improving-layouts/index.html There are some good ways to improve in your case, such as: Optimizing Layout Hierarchies Re-using Layouts with Loading Views On Demand Have fun....

Prevent double selected in ListView

android,listview,android-listview

When it's not selected you have to set a transparent/default color otherwise it will make items red after you make one item red. if(jamList.get(position).isSelected()) { convertView.setBackgroundColor(convertView.getContext().getResources().getColor(R.color.transparent_red)); } else{ convertView.setBackgroundColor(convertView.getContext().getResources().getColor(android.R.color.transparent)); } ...

performFiltering() sql exception while filtering android.

android,listview,android-listview,android-sqlite

Instead of using String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " display_name like %"+constraint.toString()+"%"; use String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " and display_name like '%"+constraint.toString()+"%'"; this may solve the problem...

Android contextual action bar with custom ListView not allowing multiple selection

android,android-listview,menuitem,contextual-action-bar,android-contextmenu

Multiple selection not exist Selected items (rows) not colored to indicate they are selected Presumably, you are not setting up the activated style for your list rows, which governs both of these. How to change... color of the CAB A custom theme should be able to do it. The...

Android Studio cannot recognize “setAdapter()” method

java,android,listview,android-listview,android-studio

Please remove } after setContentView and put new } at the end of code @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] myArray = {"biscuits", "laptops", "mice", "headphones", "macBook", "bottles", "something", "also something", "this list is stupid", "and", "dumb", "and", "useless", "okay", "here it ends"}; ListAdapter myListAdapter = new...

How to access outer class non-final variable from inner class in a Android ListView?

android,listview,android-listview

Try to declare position as final in getView() : public View getView(final int position, View convertView, ViewGroup parent) { ...

Android disable scroll and click for listview

android,listview,android-listview

You can use this for disabling the parent scrollview parentview.requestDisallowInterceptTouchEvent(true); if the overlay is visible ....

open application After incoming or outgoing call diconnection

android,android-intent,android-listview,broadcastreceiver

You have declared your PhonecallReceiver as abstract. This means that Android cannot instantiate it when it needs to. You need to rethink your architecture. BroadcastReceivers declared in the manifest cannot be abstract because Android needs to be able to instantiate them itself as needed. Either make your PhonecallReceiver concrete (not...

Resetting an Inflated ListView's height, Listview height

android,android-listview,android-studio

It will expand your listview as per your row height and width dynamically. public static void getTotalHeightofListView(ListView listView) { ListAdapter mAdapter = listView.getAdapter(); int totalHeight = 0; for (int i = 0; i < mAdapter.getCount(); i++) { View mView = mAdapter.getView(i, null, listView); mView.measure( View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); totalHeight +=...

Implemented Android AlphabetIndexer but it's not showing

android,android-listview

Actually, when I added more test data it started working. Would appear that if your search results are small (I was using about 20 or so) it doesn't kick in. Once I added some dummy data of about 100 or so then it started working.

ListView setAdapter() doesn't work

android,listview,android-fragments,android-listview

onCreate is called before onCreateView, therefore the fragments layout is not yet inflated there. You need to move your code that deals with the fragment's layout to onCreateView where all the inflation happens: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_list, container, false); String[]...

ListAdapter refuses application after changing array type to int

java,android,arrays,android-listview,android-listfragment

your getData expects a String[] and your are providing a matrix on int. You should change its signature, in order to accept an int[][] or better an int[]. If you don't want to change your adapter, let getData, convert the resource's id to String. E.g public List<String> getData(int[] res) {...

How to implement a chat list view with heterogenous row types (image video and text) using listview?

android,android-listview,chat,android-recyclerview

It can be done with recyclerview. Here is what I did for displaying multiple types of rows in a single recyclerview // Different types of rows private static final int TYPE_ITEM1 = 0; private static final int TYPE_ITEM2 = 1; public class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { class ViewHolder0 extends RecyclerView.ViewHolder...

Searchable List View

android,android-listview,listadapter

Change the code in onTextChanged() method to afterTextChanged() method as below: @Override public void afterTextChanged(Editable s) { String str=s.toString(); getSearchItems(str); } In getSearchItems use the filter properly. I used other way to filter as, public void getSearchItems(String searchText){ List<Employee> searchList=new ArrayList<Employee>(); List<Employee> employeeList=getEmployeeList(); if(employeeList2!=null){ for(Employee e:employeeList){ if(e.name.toLowerCase().contains(searchText.toLowerCase())){...

Colouring for Wearable ListView Items

java,android,listview,android-listview

constructor MyColoringAdapter in class MainActivity.MyColoringAdapter cannot be applied to given types; required: Context,String[] found: MainActivity,ArrayList reason: actual argument ArrayList cannot be converted to String[] by method invocation conversion the problem is the Constructor of your ArrayAdpater. It takes a String[] but in your Activity you are passing an ArrayList<String>...

Why When I scroll my ListView with CheckBox selected it becomes unselected?

android,listview,checkbox,android-listview

The way the ListView works is that it recycles the same views populated with different data. Hence, the need for the view holder pattern, which it looks like you are using. So, in order for your list to work correctly, you need to save the checked state to your backing...

How to delete the complete view on click of delete button in android

android,android-layout,android-activity,android-listview,android-arrayadapter

I would recommend to use an ArrayList instead of a String[] in your Adapter class. It makes it a lot easier to delete or edit a View and the associated data behind it. I used this post to convert your String[] to an ArrayList, delete the item and convert back...

Update the ListView after renaming a ListView item within a Popup Menu in a BaseAdapter in Android

android,listview,android-listview,android-arrayadapter,popupmenu

You Should re-populate the folderlist then call Notifydatasetchanged. fileNames = fileFunctions.listFileNames(Environment.getExternalStorageDirectory() + "/Documents/Files"); for(int i = 0; i < fileNames.length; i++){ folderList.add(new FolderBean(fileNames[i], "text")); } ...

Moving from one ListView to another ListView

android,listview,android-activity,android-listview,listactivity

MD already provided the ans for moving one list activity to second list activity. Just need to add dot(.) like Class ourClass = Class.forName("adnan.com.ufone." + whichItemClicked); For header problem follow This Tutorial this may help you. This tutorial fix the header and footer for all activities....

App crashes on setAdaptor() call

java,android,android-listview

You didn't initialize your LayoutInflater in your Adapter. You can initialize it in your constructor of your adapter like that: public ImageListAdaptor(ArrayList<ListItem> some, Context context) { items = some; inf = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } And when you are creating your adapter in your activity: myAdd = new ImageListAdaptor(items, this); ...

ListView Custom Adapter that includes Images from galery

android,listview,android-listview,imageview,custom-adapter

You would do this exactly as you would do with a list that contains only text. First you might want to create a class that represents an item in your list (maybe you want to add some more data, like an ID or a name), like: class ItemInMyList { Bitmap...

Losing images from NetworkImageView after Scrolling list up-down

android,android-listview,android-volley,networkimageview

Try like this in else block else { thumbnail.setVisibility(View.VISIBLE);//add this thumbnail.setImageUrl(newsArticlesItems.get(postion).getThumbnailUrl(), imageLoader); } ...

Android Persistent ListView recycling

java,android,android-listview,android-adapter

In getView() after setting the text update the visibility of the textview to Visible, since listitems in the ListView will get recycled. holder.tv1.setText(getItem(position)); holder.tv2.setText(getItem(position)); holder.tv1.setVisibility(View.VISIBLE); //Your code..... Updated : public class CustomAdapter extends BaseAdapter { private ArrayList list = new ArrayList(); private Context context; public CustomAdapter(Context context) { this.context =...

Set particular item unclickable ListView android

android,android-listview,onitemclick

In the type of TYPE_ITEM_AMOUNTS,you set the view to be disabled,and OnClickListener null,so it's not clickable,I guess this is exactly what you want; In the type of TYPE_ITEM_LIMITS,you have a Switch here,but you don't set a OnCheckedChangeListener for the switch. When you using a OnItemClickListener for a ListView,remember this:If there...

add data before sending in android dynamic listview

android,json,listview,dynamic,android-listview

Write a method in your adapter to add new items in existing list of items. and call that method in your async task when you are getting new dataset from your services/APIs.. Do not forget to put notifyDataSetChanged() in that method inside adapter.

Cancelling asynctask for list view adapter before its finished

android,android-listview,android-asynctask,adapter

Please create a list to store current AsyncTask, then cancel it anytime you want for (AsyncTask myAsyncTask : myAsyncTasks) { if (myAsyncTask.getStatus().equals(AsyncTask.Status.RUNNING)) { myAsyncTask.cancel(true); } } myAsyncTasks.clear(); Detail for your code: private List<AsyncTask> myAsyncTasks = new ArrayList<>(); public void addRunningTask(AsyncTask task) { myAsyncTasks.add(task); } public void cancelRunningTasks() { for (AsyncTask...

Unable to use string resources for list view items

java,android,android-fragments,android-listview,android-listfragment

it is because R.string.america is an integer which represent a string inside strings.xml. So you should change the type for String[][] to int[][]. If you have to assign the value to a TextVIew android will take care of the look up in strings.xml.

Ending multiselect in a listview removes list item padding

android-layout,android-listview,recyclerview,android-4.1-jelly-bean

Finally found the solution! The problem lays in the layout XML file: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list_item_doc" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?android:attr/selectableItemBackground" android:padding="12dp"> The background attribute apparenly isn't valid for Jelly Bean devices. Changing the value from android:background="?android:attr/selectableItemBackground" to...

Android SwipeRefreshLayout with empty TextView not working properly

android,android-listview,swiperefreshlayout

I solved same problem by using FrameLayout, look at below code: <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" > <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/layout_swipe_refresh" android:layout_width="match_parent" android:layout_height="wrap_content"> <ListView android:id="@+id/lv_products" android:layout_width="fill_parent" android:layout_height="wrap_content" android:divider="@null" /> </android.support.v4.widget.SwipeRefreshLayout>...

EditText in ListView loses content in scroll

android,listview,android-listview

Created a reference integer in the static ViewHolder that holds the position of clicked item in listview. Then in text watcher i set the string of the item that exists in the viewholder.reference position of my list. So, static is helping with that job. The following code is the one...

ListFragment is not updated with notifydatasetChanged

android,android-listview,android-listfragment,notifydatasetchanged

The problem is that you are setting your data source to a new reference inside the Adapter by calling this.allData=new ArrayList<SparseArray<String>>(); Once you initialize the allData list, and set it as the data source for the Adapter, you must never change the reference to a new list. There is no...

Simple ListLiew with 2 columns?

android,listview,android-listview

I think what you're looking for is a Custom ListView. It is basically a listView but you provide your own row layout (therefore, giving you better control on how many columns of data you want to display), as well as your own BaseAdapter class. Here's an example. First you need...

Populating a ListView with random data

android,xml,android-layout,android-fragments,android-listview

I'm guessing the issue is that the ListView doesn't show up. This is most likely because you're not returning the view that you're inflating and manipulating. You inflate the first view, and find the listview on that, and set the adapter (which is all correct), but then you inflate a...

data not appear in listview till i scroll it

android,android-listview

You are not setting the data when convert view is null. Which it would be in the first few passes. You only set it in the else condition. One quick fix would be to set the convert view to the view that you are creating instead of returning it at...

Reload youtubeplayer in activity? [closed]

android,android-listview,youtube-api,player

This can be done in different ways. You can use a simple WebView to load those videos. You can also use the official "YouTube Android Player API" YouTube Android Player API Implementing Youtube's API is easy, First create a YouTubePlayerViewin your xml, <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/youtubeplayerview" android:layout_width="match_parent" android:layout_height="wrap_content"/> Then show a video...

Why elements adding at the end of ListView?

android,android-layout,android-listview,android-adapter

I think this is because of your layout file. Change the android:layout_height=wrap_content of your ListView tag to android:layout_height=match_parent.