arrayadapter

Removing items from a ListAdapter not working

@Override public boolean onContextItemSelected(MenuItem item) { if(item.getTitle()=="Remove"){ AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); quotesAdapter.remove(quotes.get((int)info.id)); quotesAdapter.notifyDataSetChanged(); listView.setAdapter(quotesAdapter); serializeQuotes(); } ...

Am I creating my custom ArrayAdapter correctly?

My ListView populates correctly, but for some reason adding and removing is quirky and does not work properly! Am I doing something wrong? Set things up in OnCreate() listView = (ListView) findViewById(R.id.ListView); registerForContextMenu(listView); deserializeQuotes(); if(quotes == null || quotes.size() =...

Android Development: Problems With Creating Spinner

Hello, In my app I'm developing, I have a spinner in an alert dialog box. The spinner works fine, but when I added the following lines to add the array to the spinner, my app crashing a few seconds after starting up: ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.newFileTypeArray, android.R.layo...

How to create a dynamic context menu in android?

@Override public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Selection Options"); menu.add(0, v.getId(), 0, "Remove"); } I want my menu to say "Remove AAPL" I would get the string AAPL from ...

How do i put a vector into my arrayadapter?

I have the current code: ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, array_spinner); adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item ); colourSpinner.setAdapter(adapter); How would i put a vector into my array_spinner? Thank you. ...

Android Ellipsize marquee issues with currently selected list item

My Question - I want the text of a TextView I have in a custom ListView to marquee scroll ONLY when the item is selected in the ListView. When the list item loses focus, I want the marquee to stop scrolling. I know that I need to set the TextView to enabled (setEnabled(true)) for scrolling to work however when I do this as items are adde...

Android - list returns to top after update

I have a list that gets refreshed every 2 seconds via the Handler postDelayed() method. Every 2 seconds an AsyncTask is run that makes an HTTP GET request, turns the JSON into a list of objects, then sets the ListAdapter: MyListAdapter adapter = new MyListAdapter(someObjects); setListAdapter(adapter); My problem is that every time ...

What is "android.R.layout.simple_list_item_1"?

Hi everybody, I started learning android development. I'm following a todolist example from a book. Here is a piece of code: // Create the array list of to do items final ArrayList<String> todoItems = new ArrayList<String>(); // Create the array adapter to bind the array to the listView final ArrayAdapter<String> aa; aa = new ArrayAda...

Sorting my ArrayAdapter doesn't change my data source

I am having a weird issue. I have an ArrayAdapter which I am sorting. This displays properly on my screen, however when I check the actual data source, the contents have not been sorted. How can I ensure that sorting my ListAdapter will also sort my data source? Collections.sort(quotes, new PercentChangeComparator()); //sort my data sou...

Possible to displaying Arraylist of object's value in setListAdapter or SimpleAdapter for listview?

HI, I would like to know if it is possible to display Arraylist of object's value in setListadapter or SimpleAdapter for listview? String ArrayList works fine, I am just trying my luck with Object ArrayList ArrayList<userinfo> list = new ArrayList<userinfo>(); setListAdapter(new ArrayAdapter<userinfo>(this, R.layout.messages, list)...

ListView selection highlights multiple items in the list when scrolling

I have a custom adapter for a list in my ListActivity in my Android app. I'm dynamically setting the background color of the current item that was clicked because I want to set the marquee of the TextView in the custom list item. This is how I'm doing this: @Override protected void onListItemClick(ListView l, View v, int position, long ...

Listview's ArrayAdapter notifydatasetchanged() very slow redraw

I've a quite simple list with 3 textview fields on each row. We are updating their values every 2 seconds or so with data coming from a background webservice call ( AsyncTask ) We compare the coming values with the current ones, update them accordingly on the Adapter and finally calling notifyDataSetChanged() if needed The thing is th...

Recycling views in a listview, worth it?

When overriding the baseadapter on an android listview, you have to implement this method public View getView(int position, View convertView, ViewGroup parent). The convertview is the view that was previously pushed off the list when scrolling, and it's given so that you can reuse that view instead of creating a new view. My question is...

Android there is no ListView adapter resourceId

based on Hello-ListView turorial in Android, http://developer.android.com/resources/tutorials/views/hello-listview.html on the setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES)); had an error because there is no R.layout.list_item previously i had followed the tutorial, created the file list_item.xml on ...

getView() for ArrayAdapter is slow

When a user selects a ListViewItem, I am changing that row's background image. This seems to happen very slowly. I'm not sure why? OnItemClickListener listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { /...

How can I update one view at a time in an ArrayAdapter?

I want to be able to access my ArrayAdapter's view: public View getView(int position, View convertView, ViewGroup parent) I'm not sure how I can access this: View myView = myArrayAdapter.getView(myPosition, myView, ?); I am not sure how I can get a ViewGroup parent? ...

How can I make my ArrayAdapter follow the ViewHolder pattern?

Here is my ArrayAdapter. I would like to make this more efficient by following the ViewHolder pattern: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html but am not sure how to accomplish this. UPDATE: ViewHolder Pattern private class QuoteAdapter extends ArrayAdapter<Quote> { ...

CheckBox changes value twice

I have an Android ListView whose items have a checkbox. The checkbox is checked by default. Once unchecked it should be removed from the list. The problem is that onCheckedChanged is being fired twice: when I tap the checkbox to uncheck it (with isChecked false) and after I remove the item (with isChecked true). This is the relevant c...

ListActivity/ListView content is "disappearing"

I'm having a problem with my ListView in a ListActivity with a Custom ArrayAdapter. When the ListActivity becomes hidden (paused, whatever), the data that was present in the ArrayAdpater seems to go away. Rotation works fine, but I am only assigning the array in the ArrayAdapter in the onCreate(), nowhere else. The array is stored in ...

Double rows in a listview with ArrayAdapter (Android)

Hi everyone! I'm new to android programming and I would like some help. I have the following code: Object[] list_cities = parsedData.getCityname().toArray(); Object[] list_countries = parsedData.getCountryname().toArray(); // Display the available locations list_search.setAdapter(new ArrayAdapter<Ob...