simpleadapter

Using SimpleAdapter with Spinner

谁说胖子不能爱 提交于 2019-12-05 06:47:23
I am new to Android development. I am trying to populate a spinner by using the SimpleAdapter. But spinner's list is showing blank element. When I click any element, its text is shown properly in Toast. Please tell me what is the problem in my code below. public void onCreate(Bundle savedInstanceState) { private List<Map<String, String>> data = new ArrayList<Map<String, String>>(); String[] from = new String[] { "colorsData" }; int[] to = new int[] { R.id.spinner }; String[] colors = getResources().getStringArray(R.array.colorsData); for (int i = 0; i < colors.length; i++) { data.add(addData

android--------listview之适配器

妖精的绣舞 提交于 2019-12-04 16:17:59
ListView之适配器的使用,包含了ArrayAdapter,SimpleAdapter ,BaseAdapter等适配器。 1:ArrayAdapter /**** * * * ArrayAdapter * @author Administrator * */ public class ArrayAdapterActivity extends Activity { private ListView mListView; //定义一个String数组,数组里的数据就是ListView里的一项 String[] arrayDate={"笑傲江湖","风清扬","令狐冲","岳不群","乔峰","虚竹","段誉","中神通","东邪","西毒","南帝","北丐"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_arrayadapter); initView(); } private void initView() { mListView=(ListView)findViewById(R.id.listView1); /

How to set a simple adapter to listview?

落花浮王杯 提交于 2019-12-03 14:20:25
I have problem adding arraylist to list view, will explain about my problem here.. tell me what is wrong here... I have three linear layouts, and in the middle layout i have list view, as shown in the xml file below.. ` <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout

Deleting item from ListView deletes some another item from SQLite database

删除回忆录丶 提交于 2019-12-02 13:11:52
If I delete an item from listView suppose item_no = 5 , then some another item gets deleted from database whose id is not 5. Here is my code. My database class TRDBHelper.class //Get single reminder Cursor getReminder(int id){ SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, new String[]{COLUMN_ID, COLUMN_TITLE, COLUMN_DES, COLUMN_DATE, COLUMN_TIME}, COLUMN_ID + "=?", new String[]{String.valueOf(id)}, null, null, null, null); if(cursor != null) cursor.moveToFirst(); return cursor; } //Get all reminders public List<TRListFormat> getAllReminders(){ List

IndexOutOfBoundException on filtering SimpleAdapter

此生再无相见时 提交于 2019-12-02 12:56:08
问题 I sub classed SimpleAdapter to add some extra functionality to it, like changing background color, custom views and filtering. The background thing is working out great but the filter isn't. If I use the SimpleFilter provided by the adapter there is no problem at all, so I copied the methods from the source and put them into my adapter. Although I didn't touch anything I'll get a IndexOutOfBoundsException when typing in the search term. Usually on the second or third character. I copied the

IndexOutOfBoundException on filtering SimpleAdapter

冷暖自知 提交于 2019-12-02 05:59:27
I sub classed SimpleAdapter to add some extra functionality to it, like changing background color, custom views and filtering. The background thing is working out great but the filter isn't. If I use the SimpleFilter provided by the adapter there is no problem at all, so I copied the methods from the source and put them into my adapter. Although I didn't touch anything I'll get a IndexOutOfBoundsException when typing in the search term. Usually on the second or third character. I copied the whole class but the interesting part is the CustomFilter bindView and getView is working great. After

How to update ListView after onResume from other activity?

百般思念 提交于 2019-12-01 11:16:33
Im trying to create an application that enable user to create event, then invite participant. So when user go to "add participant" page, after entering all information, im trying to direct back to the "participant list" page by using onResume(), but how to update the listview? i tried to use notifyDataSetChanged() but not working. Here is the code for participant list: public class EventPage extends ListActivity implements OnClickListener { Intent intent; TextView friendId; EventController controller = new EventController(this); TabHost th; Button addparticipant; String eventId; ListView lv;

How to update ListView after onResume from other activity?

柔情痞子 提交于 2019-12-01 08:51:55
问题 Im trying to create an application that enable user to create event, then invite participant. So when user go to "add participant" page, after entering all information, im trying to direct back to the "participant list" page by using onResume(), but how to update the listview? i tried to use notifyDataSetChanged() but not working. Here is the code for participant list: public class EventPage extends ListActivity implements OnClickListener { Intent intent; TextView friendId; EventController

After filter a listview,how can I obtain the position of the first listview?

好久不见. 提交于 2019-12-01 02:23:55
After filter a listview,how can I obtain the position of the first listview? I use simpleadapter to fill the listview. Each item in the datasource has its own id,and I use "case" to redirect them. After I filter the listview ,I don't know how to associate the latter items with the first listview.The postion and id have changed. Thank you. I use the afterTextChanged of EditTextView to filter the listview and notify it. @Override public void afterTextChanged(Editable paramEditable) { listItemsCopy.clear(); int count=simpleAdapter.getCount(); if ((count>0 )&&paramEditable.length()>0) { for (int i

How to use SimpleAdapter.ViewBinder?

随声附和 提交于 2019-12-01 01:27:23
I have a list with a complex layout R.layout.menu_row . It consists of a ProgressBar and a text field. The adapter I use: SimpleAdapter simpleAdapter = new SimpleAdapter(this, getData(path), R.layout.menu_row, new String[] { "title", "progress" }, new int[] { R.id.text1,R.id.progressBar1}); The adapter knows how to handle TextViews by it self but not ProgressBars , so I wrote a complex data binder: SimpleAdapter.ViewBinder viewBinder = new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { //here goes the code if () { return