android-arrayadapter

How to disable ListView item after it has been clicked?

北慕城南 提交于 2019-12-12 13:29:03
问题 I have a simple array of Strings that I was displaying in a horizontal ListView with an ArrayAdapter . What I'm looking to do is: when the user selects an item from the ListView , make that item not clickable and change the background color of that item. Perhaps like a "grayed-out" look to it. I was looking into creating a custom Adapter and overriding the isEnabled(int position) method but I don't know how I would go about this. Any advice, suggestions, or help will be greatly appreciated

How to get context of an activity extending ListFragment from its adapter class?

萝らか妹 提交于 2019-12-12 10:55:31
问题 This is my adapter class where I want to call startActionMode. I call it inside setActionMode method but got these errors: Cannot cast from Context to ActivityFragment. The method startActionMode(ActivityFragment.ActionModeCallback) is undefined for the type ActivityFragment. public class ListAdapter extends ArrayAdapter<ListGettersSetters> { ArrayList<ListGettersSetters> arrayListGettersSetters; LayoutInflater layoutInflater; Context context; int Resource, i = 0, j = 0, checkedItemsCount = 0

Spinner with custom ArrayAdapter for objects not displaying selected item

假如想象 提交于 2019-12-12 10:54:55
问题 I have a custom ArrayAdapter to represent objects on a spinner control, I can load my items list and show it for selection, but when the actual selection happens the spinner shows nothing. Activity code: public MetroData metroData; private Spinner spinner; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); metroData = new MetroData(); spinner = (Spinner) findViewById(R.id.spinner1); StopArrayAdapter dAdapter = new

NullPointerException at android widget ArrayAdapter createViewFromResource

只愿长相守 提交于 2019-12-12 10:29:13
问题 I am a new to android ArrayAdapters and I am facing a null pointer exception when populating my ListView. The data which I used to populate the listview is not null, I had checked that. Also the whole thing is working fine on first load, but once I scroll down to the end of the list, the App crashes. Here is my stack trace: E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NullPointerException at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394) at android.widget

How change color of specific item of listview?

半世苍凉 提交于 2019-12-12 09:41:33
问题 I have a customlistadapter as follow: public class CustomListViewAdapter2 extends ArrayAdapter<RowItem> { List<Integer> baseOnThis; public CustomListViewAdapter2(Context context, int resourceId, List<RowItem> items, ArrayList<Integer> ids) { super(context, resourceId, items); this.context = context; baseOnThis= ids; } /* private view holder class */ private class ViewHolder { TextView firstHemistich; TextView SecondHemistich; } public View getView(int position, View convertView, ViewGroup

How to set different heights for each row in a ListView?

牧云@^-^@ 提交于 2019-12-12 07:26:29
问题 I have problem setting the height of a single row in a ListView. I have already read hundreds of forums and blog posts, but nothing seems to work for me. I have a ListView with an ArrayAdapter<Order> . Depending on an attributes of the Order object, different Layouts are used, with different heights for each row. However, in the end, all rows have the same height. I suppose it is the height of the layout given to the constructor of the ArrayAdapter. Does anybody know how to control the height

How to get all .mp3 files from raw folder to custom array listview and play that song?

我的梦境 提交于 2019-12-12 07:01:42
问题 I am developing one app that can play .mp3 file.So,In this app i have created one custom listview adapter for populating the .mp3 files from raw folder to listview and created one model class and in my raw folder i have 20 .mp3 files.So, I want to add this all raw folder .mp3 files to listview in each row.after that when user click that particular listview item at that time play that song given position. Note: I am not importing that .mp3 files from SDCARD. Here this my adapter public class

Android Dev: Attempting to style/color resulting string with ArrayAdapter

孤者浪人 提交于 2019-12-12 06:45:47
问题 Is there a way to color/style certain portions of the resulting string? I have a ListView layout, and the following onCreate method for the corresponding Activity. public class AddressesActivity extends ListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.addresses); AddressDBHandler datasource = new AddressDBHandler(this); datasource.open(); List<Address> values = datasource.getAllAddresses(); ArrayAdapter

Observer was not registered. ListView Adapter crashing sometime

浪尽此生 提交于 2019-12-12 05:39:40
问题 I have a service that is downloading some photos album data and there is a Activity. The serveice has a reference of Activity and calls method of the activity notifying the UI to show latest list data that is in queue. The service calls an activity-method that has as handler to update UI e.g public void askForChecheList ( ) { galleryHandler.sendEmptyMessage ( 5 ) ; } Where handler is like private Handler galleryHandler = new Handler() { @ Override public void handleMessage (Message msg) { //

Updating listView without duplication

别说谁变了你拦得住时间么 提交于 2019-12-12 05:36:50
问题 I am writing a music player application with playlists, and I am trying to display the songs that have been chosen. All of the code for that works fine, but when a song is added, the listView won't update. I have searched extensively online, but cannot figure out how to fix it. I ended up trying to call leftAdapter.notifyDataSetChanged(); to update the list, but it throws the error: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ArrayAdapter