android-arrayadapter

Android - ListView not being updated after adding to SQLite database unless app is restarted

百般思念 提交于 2019-12-23 04:54:42
问题 I am currently trying to populate a ListView by querying a SQLite database which feeds the adapter, which I can update by adding an entry. However, the ListView doesn't get updated unless I restart the app. Here is my data source code: public class DataSource { // Database fields private SQLiteDatabase database; private SQLHelper dbHelper; private String[] allColumns = null; public DataSource(Context context) { dbHelper = new SQLHelper(context); } public void open() throws SQLException {

Custom Array adapter for chat app

江枫思渺然 提交于 2019-12-23 03:31:15
问题 I'm creating Bluetooth chat app and I'm kinda new to Android programming. Atm my app can manage bluetooth connection and send/receive data. My problem is populating list view with strings because I'm not so good with creating Custom ArrayAdapters. I have 2 shapes (Red and Blue bubble) for sent and received messages (R.drawable.rounded_corner and R.drawable.rounded_corner_get). I'm managing bluetooth connection(ConnectedThread) in activity(MessengerActivity) as you can see in code bellow. So

Android ListView with ArrayAdapter replacing list item components

五迷三道 提交于 2019-12-23 03:19:19
问题 Please check the last update down below as I found the issue but don't know how to fix it [Update: project download link] which is very tiny it's just a sample and added Questions class I'm creating a ListView with ArrayAdapter for a quiz. every question has 3 answers as radio buttons. The problem is when I scroll down or up again it replaces the answers of the first question with answers of another question which was hidden by the scroll and replaces the hidden question answers with the

Sorting Custom Listview Items Using Spinner Android

我怕爱的太早我们不能终老 提交于 2019-12-23 02:42:36
问题 I am attempting to sort the items in a listview both alphabetically and numerically upon selection of the sorting style using a spinner. Essentially whenever the user selects a spinner item the listview will be sorted according the option they chose. Since this is a custom listview with a custom adapter I have been having some issues finding a way to actually sort it properly. If anyone can give me some advice on how I can go about this it would be greatly appreciated. Below is what I have

How do I use ArrayAdapter to display a list view?

浪子不回头ぞ 提交于 2019-12-23 02:28:39
问题 I want to display a list view in my application. Each row should contain a text and an image. I have used ArrayAdapter to display this but how to insert an image after the text. Here is the code: String lvr[]={"Android","iPhone","BlackBerry","AndroidPeople"}; super.onCreate(savedInstanceState); setContentView(R.layout.main); list1 = (ListView) findViewById(R.id.cg_listview1); list1.setAdapter(new ArrayAdapter<String>(this,R.layout.alerts , lvr)); Here alerts is my layout which contains only a

context parameter for custom adapter - getApplicationContext() fails but 'this' works

天涯浪子 提交于 2019-12-23 02:04:26
问题 I have simple code snippet to implement custom list view. In this code, I have CustomAdapter class which extends ArrayAdapter : CustomAdapter adapter = new CustomerAdapter(getApplicationContext(),R.layout.listview_item_row, weather_data); The constructor of CustomAdapter is as below: public CustomerAdapter(Context context, int layoutResourceId, weather[] data) { super(context, layoutResourceId, data); mlayoutResourceId = layoutResourceId; mcontext = context; mdata = data; } If I write this,

context parameter for custom adapter - getApplicationContext() fails but 'this' works

亡梦爱人 提交于 2019-12-23 02:04:15
问题 I have simple code snippet to implement custom list view. In this code, I have CustomAdapter class which extends ArrayAdapter : CustomAdapter adapter = new CustomerAdapter(getApplicationContext(),R.layout.listview_item_row, weather_data); The constructor of CustomAdapter is as below: public CustomerAdapter(Context context, int layoutResourceId, weather[] data) { super(context, layoutResourceId, data); mlayoutResourceId = layoutResourceId; mcontext = context; mdata = data; } If I write this,

How to delete a custom listview item in android?

天大地大妈咪最大 提交于 2019-12-22 17:39:19
问题 I have a listview and a button in my layout file. I'am adding items to listview on click of that button. The listview should be empty when the activity is started but it should grow by adding the items to it. This is my code inside onCreate() : list = (ListView)findViewById(R.id.inverterListView); adapter = new ArrayAdapter<String>(InverterList.this, R.layout.inverters_list_row, R.id.inverterNumberTextViewInPanelListRow); list.setAdapter(adapter); And here iam adding the items to listview

How to update an item from ArrayList on ArrayAdapter in Android

大兔子大兔子 提交于 2019-12-22 17:22:21
问题 I am new at developing Android.I have a ListView and custom ArrayAdapter which holds an arraylist.I want to update arraylist specific item by position.How can I handle please help me thanks in advance. 回答1: Assuming your adapter is storing a List of Foo objects. Foo item = mAdapter.getItem(position); item.setValue("blah"); //Or whatever you need to update mAdapter.notifyDataSetChanged(); 来源: https://stackoverflow.com/questions/27344840/how-to-update-an-item-from-arraylist-on-arrayadapter-in

Spinner with custom array adapter doesn't allow selecting item

雨燕双飞 提交于 2019-12-22 12:26:50
问题 I use a custom array adapter for a spinner. However, when selecting an item in the dropdown list, the dropdown list stays there, and the spinner doesn't get updated, which is misbehaviour (compared to using a generic array adapter with string). This is the custom class. Am I missing anything? thanks. public class CalendarNameAdapter extends ArrayAdapter<AgendaLogic.ExternalCalendarInfo> { Context mContext ; ArrayList<AgendaLogic.ExternalCalendarInfo> mCalendarLayers; public