Search Results

Search found 135 results on 6 pages for 'listactivity'.

Page 2/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Exception when creating an activity: Could not select item Parcel unable to marshal value

    - by user341652
    Hi, I am trying to call an Activity from another instance of the activity. The code is supposed to be a simple file browser (part of a larger application). I am using a ListActivity, and when an item (such as a folder) is selected, it is supposed to open it up in the new Activity. I have a feeling it is a problem with the AndroidManifest (which just has the basic tag). Any assistance would be appreciated. Thanks, Steve

    Read the article

  • call setListAdapter() from inside a thread

    - by Mats Hofman
    Hi, I have a problem with my ListActivity, i use a thread to show a ProgressDialog where get a list of all installed applications. I turn it into a list adapter and than i want to set the listadapter of the activity but i can't do that from the thread. I get the following error: ERROR/AndroidRuntime(14429): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. new Thread() { public void run() { showList(); // the method where i get all the apps and have the setListAdapter(); method progressDialog.dismiss(); } }.start(); How do I get it so I can use the setListAdapter from inside my thread

    Read the article

  • Why / When / How is this Android serviceBinder resetting to null?

    - by GaZ
    I've written a ListActivity for Android 2.1 which is used to display a list of event categories. As the user selects a category, the program calls a web service to retrieve a list of sub-events. For example, a top level event might be "soccer" and when the user selects this the web service would return various soccer associations (e.g. "english", "french", "german", etc.) and display them in a new list. The following code seems to work occasionally, however sometimes the call to the service (in EventsListTask) fails because the serviceBinder is null. How/Why does this happen? public class EventListsActivity extends ListActivity { private static final String EVENT_ID = "EventId"; private List<ListItem> eventList; private ArrayAdapter<ListItem> listItemArrayAdapter; private static final int LOADING_DIALOG = 1; private EventsListTask eventsListTask = null; private BFService serviceBinder; private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName componentName, IBinder iBinder) { Log.i("EventListsActivity", "service connected"); serviceBinder = ((BFService.BFBinder)iBinder).getService(); } public void onServiceDisconnected(ComponentName componentName) { Log.i("EventListsActivity", "service disconnected"); serviceBinder = null; } }; @Override public void onCreate(Bundle savedInstanceState) { Log.i("EventListsActivity", "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.list); eventList = new ArrayList<ListItem>(); listItemArrayAdapter = new ArrayAdapter<ListItem>(this, R.layout.row, eventList); setListAdapter(listItemArrayAdapter); Intent bindIntent = new Intent(this, BFService.class); bindService(bindIntent, mConnection, Context.BIND_AUTO_CREATE); int eventId = getIntent().getIntExtra(EVENT_ID, -1); if (eventsListTask == null || eventsListTask.getStatus() == AsyncTask.Status.FINISHED) { eventsListTask = new EventsListTask(); eventsListTask.execute(eventId); } } @Override protected void onDestroy() { Log.i("EventListsActivity", "destroyed"); super.onDestroy(); unbindService(mConnection); } @Override protected void onListItemClick(ListView listView, View view, int position, long id) { super.onListItemClick(listView, view, position, id); ListItem selectedItem = (ListItem) listView.getAdapter().getItem(position); Intent intent; if (selectedItem.getMarketType() != null) { intent = new Intent(this, MarketActivity.class); intent.putExtra(EVENT_ID, selectedItem.getId()); startActivityIfNeeded(intent, -1); } else if (selectedItem.getId() != -1) { intent = new Intent(this, EventListsActivity.class); intent.putExtra(EVENT_ID, selectedItem.getId()); startActivityIfNeeded(intent, -1); } else { Log.e("EventListsActivity", "unexpected item selected!"); } } @Override protected Dialog onCreateDialog(int id) { switch (id) { case (LOADING_DIALOG) : AlertDialog.Builder loadingDialog = new AlertDialog.Builder(this); loadingDialog.setTitle("Please Wait..."); loadingDialog.setMessage("Communicating with remote service."); return loadingDialog.create(); } return null; } private class EventsListTask extends AsyncTask<Integer, Void, LoginStatusEnum> { @Override protected void onPreExecute() { showDialog(LOADING_DIALOG); } @Override protected void onPostExecute(LoginStatusEnum loginStatusEnum) { dismissDialog(LOADING_DIALOG); if (loginStatusEnum != null) { switch (loginStatusEnum) { case OK: for (ListItem item : eventList) { listItemArrayAdapter.add(item); } listItemArrayAdapter.notifyDataSetChanged(); break; } } } @Override protected LoginStatusEnum doInBackground(Integer... params) { LoginStatusEnum result = LoginStatusEnum.OK; Integer eventId = params[0]; if (serviceBinder != null) { try { if (eventId == null || eventId == -1) { eventList = serviceBinder.getActiveEventTypes(); } else { eventList = serviceBinder.getEvents(eventId); } } catch (WebServiceException wse) { result = LoginStatusEnum.valueOf(wse.getMessage()); } } else { Log.e("EventListsActivity", "serviceBinder is null!"); } return result; } } } EDIT: The serviceBinder appears to be set to null when I reach the bottom of a list, when I change the target intent to go to a different activity: intent = new Intent(this, MarketActivity.class); intent.putExtra(EVENT_ID, selectedItem.getId()); startActivity(intent); This new activity also uses the same background service (binds in the same way, etc.). Is there anything I need to watch out for when doing this? Am I calling the target intent incorrectly? EDIT2: Here's the output from LogCat when I start the activity which calls the service (this time the service failed straight away!): 04-02 07:02:49.147: INFO/ActivityManager(61): Starting activity: Intent { cmp=net.foobar.activity/.EventListsActivity } 04-02 07:02:49.257: INFO/EventListsActivity(353): onCreate 04-02 07:02:49.426: INFO/EventListsActivity(353): service connected 04-02 07:02:49.437: ERROR/EventListsActivity(353): serviceBinder is null!

    Read the article

  • What is the best way to do multiple listviews in android?

    - by Nicos
    Hi all, i am writing a software that i have to drill down on content a lot. For example when the program starts a listview is displayed. When user clicks on an item, then a second listview must be displayed. For example: Select Continent Select Country Select State Select City Select Address What is the best way to do this (less memory, faster, easier to code etc)? To create multiple listviews with multiple adapters? Or 1 listview with multiple Adapters? Lists are loaded from an external XML File. So far i am creating a new adapter and setting it to the listview. How do i create a second listview and after clicking on 1st listview displaying the second one, with animation. Any examples? Extend my class to ListActivity or Activity? Best regards and thanks for helping, Nicos

    Read the article

  • Unknown ListView Behavior

    - by st0le
    I'm currently making a SMS Application in Android, the following is a code snippet from Inbox Listactivity, I have requested a cursor from the contentresolver and used a custom adapter to add custom views into the list. Now, in the custom view i've got 2 TextViews (tvFullBody,*tvBody*)... tvFullBody contains the Full SMS Text while tvBody contains a short preview (35 characters) The tvFullBody Visibility is by default set to GONE. My idea is, when the user clicks on a list item, the tvBody should dissappear(GONE) and the tvFullBody should become visible (VISIBLE). On Clicking again, it should revert back to its original state. //isExpanded is a BitSet of the size = no of list items...keeps track of which items are expanded and which are not @Override protected void onListItemClick(ListView l, View v, int position, long id) { if(isExpanded.get(position)) { v.findViewById(R.id.tvFullBody).setVisibility(View.GONE); v.findViewById(R.id.tvBody).setVisibility(View.VISIBLE); }else { v.findViewById(R.id.tvFullBody).setVisibility(View.VISIBLE); v.findViewById(R.id.tvBody).setVisibility(View.GONE); } isExpanded.flip(position); super.onListItemClick(l, v, position, id); } The Code works as it is supposed to :) except for an undesired sideeffect.... Every 10th (or so) List Item also gets "toggled". eg. If i Expand the 1st, then the 11th, 21th list items are also expanded...Although they remain off screen, but on scrolling you get to see the undesired "expansion". By my novice analysis, i'm guessing Listview keeps track of 10 list items that are currently visible, upon scrolling, it "reuses" those same variables, which is causing this problem...(i didn't check the android source code yet.) I'd be gratefull for any suggestion, on how i should tackle this! :) I'm open to alternative methods aswell....Thanks in advance! :)

    Read the article

  • How to use Selector when click a item in list

    - by notenking
    I occur a problem when develop a application on android. There have two image which can be download from server in a list item, it will show one image and will show another image when user select or click this item . if I try to download another image from server when user click it,the user will never have time to see it, for this time is shorter than download image form server, so i want to download two of them,and when I click it again,the app can invoke another image from local. but I do not know how to invoke this image ? Any suggestion will be appreciate. thx

    Read the article

  • Where are graphically pleasing examples of Lists

    - by slim
    Anyone know of good code examples of how to make lists look different than your everyday average black list or more graphically pleasing than you usually see in android apps. I've looked through google code but haven't found too many. I'm looking for different and eye catching lists. I hope this question isn't too generic. Also i'm open to anything, code, examples, blog posts, etc, you name it. I've really struggled with lists and making them look more snazzy. I'm talking more the code level not the graphics or icons used.

    Read the article

  • How to correctly populate records from SQLlite in ListActivity?

    - by Pavel
    Hi. Can someone please tell me how can I easily display every record from sqllite in ListActivity tab? I'm kinda confused with this. Do I have to create db from my helper class in TabActivity or ListActivity or both? My db helper class is as follow: package tabs.app; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; public class DBAdapter { private static String DB_PATH = "/data/data/tabs.app/databases/"; public static final String KEY_ROWID = "_id"; public static final String KEY_LATITUDE = "latitude"; public static final String KEY_LONGITUDE = "longitude"; private static final String TAG = "DBAdapter"; private static final String DATABASE_NAME = "coords"; private static final String DATABASE_TABLE = "coordsStorages"; private static final int DATABASE_VERSION = 2; /* private static final String DATABASE_CREATE = "create table coordsStorage (_id integer primary key autoincrement, latitude integer not null, longitude integer not null)"; */ public Context context; private DatabaseHelper DBHelper; private SQLiteDatabase db; public DBAdapter(Context ctx) { this.context = ctx; DBHelper = new DatabaseHelper(context); } private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("create table coordsStorages (_id integer primary key autoincrement, latitude integer not null, longitude integer not null)"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.w(TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data"); db.execSQL("DROP TABLE IF EXISTS titles"); onCreate(db); } } //---opens the database--- public DBAdapter open() throws SQLException { db = DBHelper.getWritableDatabase(); return this; } //---closes the database--- public void close() { DBHelper.close(); } //---insert a title into the database--- public long insertCoords(int latitude, int longitude) { ContentValues initialValues = new ContentValues(); initialValues.put(KEY_LATITUDE, latitude); initialValues.put(KEY_LONGITUDE, longitude); return db.insert(DATABASE_TABLE, null, initialValues); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DATABASE_NAME; db = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } //---deletes a particular title--- public boolean deleteTitle(long rowId) { return db.delete(DATABASE_TABLE, KEY_ROWID + "=" + rowId, null) > 0; } //---retrieves all the titles--- public Cursor getAllTitles() { return db.query(DATABASE_TABLE, new String[] { KEY_ROWID, KEY_LATITUDE, KEY_LONGITUDE}, null, null, null, null, null); } //---retrieves a particular title--- public Cursor getTitle(long rowId) throws SQLException { Cursor mCursor = db.query(true, DATABASE_TABLE, new String[] { KEY_ROWID, KEY_LATITUDE, KEY_LONGITUDE}, KEY_ROWID + "=" + rowId, null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } //---updates a title--- /*public boolean updateTitle(long rowId, int latitude, int longitude) { ContentValues args = new ContentValues(); args.put(KEY_LATITUDE, latitude); args.put(KEY_LONGITUDE, longitude); return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null) > 0; }*/ } And Im trying to retrieve the records in TabActivity like this: public class Areas extends ListActivity { DBAdapter db; SimpleCursorAdapter mAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.areas_layout); db = new DBAdapter(this); db.open(); Cursor c = db.getAllTitles(); startManagingCursor(c); String[] display = new String[] { db.KEY_LATITUDE }; int[] to = new int[] { R.id.row_latitude}; /* String[] display2 = new String[] { db.KEY_LONGITUDE }; int[] to2 = new int[] { R.id.row_longitude};*/ mAdapter = new SimpleCursorAdapter(this, R.layout.areas_layout, c, display, to); setListAdapter(mAdapter); /* mAdapter2 = new SimpleCursorAdapter(this, R.layout.areas_layout, c, display2, to2); setListAdapter(mAdapter2);*/ db.close(); } /* private void fillData() { // Get all of the rows from the database and create the item list Cursor c = db.getAllTitles(); startManagingCursor(c); }*/ } Whenever I'm trying to do that the error log outputs this: 06-07 09:51:56.529: ERROR/AndroidRuntime(2034): Uncaught handler: thread main exiting due to uncaught exception 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): java.lang.RuntimeException: Unable to start activity ComponentInfo{tabs.app/tabs.app.Areas}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2242) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:631) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.widget.TabHost.setCurrentTab(TabHost.java:317) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:127) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:346) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.View.performClick(View.java:2344) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.View.onTouchEvent(View.java:4133) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.View.dispatchTouchEvent(View.java:3672) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:850) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.Activity.dispatchTouchEvent(Activity.java:1987) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.view.ViewRoot.handleMessage(ViewRoot.java:1658) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.os.Handler.dispatchMessage(Handler.java:99) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.os.Looper.loop(Looper.java:123) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.ActivityThread.main(ActivityThread.java:4203) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at java.lang.reflect.Method.invokeNative(Native Method) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at java.lang.reflect.Method.invoke(Method.java:521) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at dalvik.system.NativeStart.main(Native Method) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.ListActivity.onContentChanged(ListActivity.java:236) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.Activity.setContentView(Activity.java:1620) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at tabs.app.Areas.onCreate(Areas.java:18) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364) 06-07 09:51:56.559: ERROR/AndroidRuntime(2034): ... 30 more 06-07 09:51:56.619: INFO/Process(51): Sending signal. PID: 2034 SIG: 3 06-07 09:51:56.619: INFO/dalvikvm(2034): threadid=7: reacting to signal 3 06-07 09:51:56.619: ERROR/dalvikvm(2034): Unable to open stack trace file '/data/anr/traces.txt': Permission denied Can someone please tell me what I'm doing wrong? Help greatly appreciated!

    Read the article

  • In Android ListActivity, how do you apply layout formatting to footers?

    - by johnrock
    In an Android ListActivity, I am adding a button as a footer in a ListView. How can I apply layout formatting to this button like centering it and/or width=fill_parent? I have tried a few things such as using setLayoutParams(), but have not gotten it to work - the footer always disappears when I try anything. Here is the basic code I am working with closeButton = new Button(this); closeButton.setText(getResources().getString(R.string.title_closeprocess)); closeButton.setOnClickListener(new OnClickListener(){ public void onClick(View v) { closeProcess(); } }); getListView().addFooterView(closeButton);

    Read the article

  • Fragments keep going back to the default position when MapView is Zoomed In/Out

    - by hectichavana
    I have an activity with 3 fragments displayed, a MapActivity, a ListActivity, and a (normal) DetailsActivity. The ListActivity and DetailsActivity is placed over the MapActivity. There's a function to hide both ListActivity and DetailsActivity with an Animation, and onAnimationEnd() I set a new layout for the hidden Activity. The problem I'm facing is, everytime one of the ListActivity or DetailsActivity hidden (picture State 2), and then I pinch the screen on the MapActivity to zoom the map, it always goes back to the default view (picture State 1). The closed Activities are automatically opened again. Does anybody know how to prevent the hidden fragments from going to the first state again when I pinch the MapActivity? this is an example of the function how I hide the DetailsActivity(): public void hideDetailview() { final Animation close = AnimationUtils.loadAnimation(this, R.anim.close); close.setFillEnabled(true); close.setAnimationListener(closeDetailAnimationListener); fragment_detail.startAnimation(close); Toast.makeText(MainFragmentActivity.this,WWHApplication.getDrawer(), Toast.LENGTH_SHORT).show(); } private AnimationListener closeDetailAnimationListener = new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { int newLeft = -330; fragment_detail.layout(newLeft, fragment_detail.getTop(), newLeft + fragment_detail.getMeasuredWidth(), fragment_detail.getTop() + fragment_detail.getMeasuredHeight()); } };

    Read the article

  • android: having two listviews in two listactivities didn't work

    - by Yang
    I guess my previous question wasn't clear enough (http://stackoverflow.com/questions/2549585/android-failed-to-setcontentview-when-switching-to-listactivity), so I explain as follows. In my app I have two listactivities which uses two different listviews: public class Activity1 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { try{ super.onCreate(savedInstanceState); setContentView(R.layout.listview1); } public class Activity2 extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { try{ super.onCreate(savedInstanceState); setContentView(R.layout.listview2); } } As required by android, listview must have an ID which is exactly "@android:id/list". If I set the listview in both listview1 and listview2 with the same ID, then they will end up using the same format of listview, which is not what I want. But if I set one of the IDs to be sth like "@+id/listview2", android gave me the error: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list' How do I handle this dilema?

    Read the article

  • Try to use Window.FEATURU_CUSTOM_TITLE but got Exception:You cannot combine custom titles with other

    - by xueru
    I am trying to use a custom title to include an image button to the title bar. I got a lot of help form this post: http://stackoverflow.com/questions/2569753/android-adding-button-to-the-title-of-the-app, but could not get it work for my ListActivity. In a nutshell, following is what I have: I hide the titlebar in the AndroidManifest.xml The specify a relative layout for the custom title (workorder_list_titlebar.xml) My Activity Class looks like the following: public class WorkOrderListActivity extends ListActivity { String[] orders={"WO-12022009", "WO-12302009", "WO-02122010", "02152010"}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.workorder_list_titlebar); setContentView(R.layout.workorder_list); setListAdapter(new ArrayAdapter(this,R.layout.workorder_list, R.id.label,orders)); } } When I ran the app, I got AndroidRuntimeException: You cannot combine custom titles with other title features. Base on the stack trace, the exception was thrown by com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:183), that was triggered by setlistAdapter call. Does anyone have the same problem with ListActivity? Also once I manage to get this work, how do I attach listeners to the image button for it to do something? Thanks in advance.

    Read the article

  • StaleDataException: access closed cursor

    - by Aurora
    In my application, after enough clicking around, I get this error: 06-08 19:47:59.967: ERROR/AndroidRuntime(2429): java.lang.RuntimeException: Unable to pause activity {com.MYAPP.app/com.MYAPP.app.MainActivity}: android.database.StaleDataException: Access closed cursor What I have is a Tab Activity (my MainActivity), which has a ListActivity as the contents for each tab. Inside the onCreate for each ListActivity I get a cursor that represents the data to be displayed in that list. The onListItemClick for each list also creates another activity, so clicking on an item in the list will show more information about that item in a new screen. It's inconsistent, but after enough clicking into these new activities, or going back to the ListView from a new activity, the program crashes. In searching around for a solution to my problem, I did stumble upon registerDataSetObserver, but it doesn't seem to be the whole answer. I am also having trouble finding documentation on it, so I'm not sure I fully understand it. I have a custom ListAdapter that both my ListViews use and have called registerDataSetObservers on the cursors there. I have attached the relevant code from one of my ListActivities and from my custom ListAdapter class. The ListActivity. I have two of these, almost identical, except they both have different cursors created from different database queries: import com.MYAPP.app.listmanager.DeviceListAdapter; public class AllSensorsActivity extends ListActivity{ private DeviceListAdapter AllList; private DbManager db; protected Cursor AllCur; protected Cursor AllSensors; private static final String TAG = "AllSensorsActivity"; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Log.e(TAG, "Calling All onCreate"); db = new DbManager(this); db.open(); AllCur = db.fetchAllDevices(); startManagingCursor(AllCur); AllSensors = db.fetchAllSensors(); startManagingCursor(AllSensors); AllList = new DeviceListAdapter(this, AllCur, AllSensors); setListAdapter(AllList); } @Override protected void onListItemClick(ListView l, View v, int position, long id){ String device_name = (String) ((DeviceListAdapter)getListAdapter()).getItem(position); String sensor_string = ((DeviceListAdapter)getListAdapter()).getSensors(id); Intent i = new Intent(this, SensorActivity.class); Bundle bundle = new Bundle(); bundle.putString("NAME", device_name); i.putExtras(bundle); bundle.putString("SENSORS", sensor_string); i.putExtras(bundle); this.startActivity(i); } The custom ListAdapter: public class DeviceListAdapter extends BaseAdapter { private static final String TAG = "DeviceListAdapter"; private Context mContext; private Cursor mSensors; private Cursor mDevices; protected MyDataSetObserver sensors_observer; protected MyDataSetObserver devices_observer; public DeviceListAdapter(Context context, Cursor devices, Cursor sensors){ mContext = context; mDevices = devices; mSensors = sensors; sensors_observer = new MyDataSetObserver(); mSensors.registerDataSetObserver(sensors_observer); devices_observer = new MyDataSetObserver(); mDevices.registerDataSetObserver(devices_observer); } // ... more functions and stuff that are not relevant go down here... } private class MyDataSetObserver extends DataSetObserver { public void onChanged(){ Log.e(TAG, "CHANGED CURSOR!"); } public void onInvalidated(){ Log.e(TAG, "INVALIDATED CURSOR!"); } } Should I just have MyDataSetObserver catch the exception and move on? I'd like a more robust solution than that if possible. Or is there some other way I could rearrange my program so that the staleDataException doesn't occur (as often)? I believe that it is happening because I am launching the new activity in my onListItemClick.

    Read the article

  • Kindle Fire: PopupMenu$OrientationChangeListener leak

    - by dokkaebi
    I have a little popup menu that anchors on a button in the action bar. This works well on 3.0/3.1 Xoom and Galaxy tabs, and a 4.1 Nexus 7. However, on a 7" Fire HD (this one), I get an error about a leaked intent receiver when exiting the application. The error occurs only if the menu was not opened during that run. There is no mention of OrientationChangeListener in the one copy of the source I've found; I suspect Amazon has a different implementation. Questions: Has anyone encountered this? Does anyone know of a workaround or a fix? (Where) can I find Amazon's source code? Finally, (shudder) how important is it that I don't leak a receiver on application exit? Here is the menu xml: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_profile" android:title="@string/menu_item_profile" ></item> <item android:id="@+id/menu_logout" android:title="@string/menu_item_logout" ></item> </menu> This is where I register it: @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); MenuItem login = menu.findItem(R.id.menu_login); Button button = (Button) login.getActionView().findViewById(R.id.login); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { profileMenu.show(); } }); // profileMenu is an instance field profileMenu = new PopupMenu(this, button); inflater.inflate(R.menu.profile_menu, profileMenu.getMenu()); profileMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // there was code here, but I removed it all and the problem persists return false; } }); return true; } Here is the full stack trace: 10-21 20:55:28.461: E/ActivityThread(4526): Activity **.app.ListActivity has leaked IntentReceiver android.widget.PopupMenu$OrientationChangeListener@422d77e0 that was originally registered here. Are you missing a call to unregisterReceiver()? 10-21 20:55:28.461: E/ActivityThread(4526): android.app.IntentReceiverLeaked: Activity **.app.ListActivity has leaked IntentReceiver android.widget.PopupMenu$OrientationChangeListener@422d77e0 that was originally registered here. Are you missing a call to unregisterReceiver()? 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:826) 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:621) 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1072) 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1059) 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1053) 10-21 20:55:28.461: E/ActivityThread(4526): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:357) 10-21 20:55:28.461: E/ActivityThread(4526): at android.widget.PopupMenu.<init>(PopupMenu.java:81) 10-21 20:55:28.461: E/ActivityThread(4526): at **.app.ListActivity.onCreateOptionsMenu(ListActivity.java:350) 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.Activity.onCreatePanelMenu(Activity.java:2558) 10-21 20:55:28.461: E/ActivityThread(4526): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:398) 10-21 20:55:28.461: E/ActivityThread(4526): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:883) 10-21 20:55:28.461: E/ActivityThread(4526): at com.android.internal.policy.impl.PhoneWindow$2.run(PhoneWindow.java:3008) 10-21 20:55:28.461: E/ActivityThread(4526): at android.os.Handler.handleCallback(Handler.java:605) 10-21 20:55:28.461: E/ActivityThread(4526): at android.os.Handler.dispatchMessage(Handler.java:92) 10-21 20:55:28.461: E/ActivityThread(4526): at android.os.Looper.loop(Looper.java:137) 10-21 20:55:28.461: E/ActivityThread(4526): at android.app.ActivityThread.main(ActivityThread.java:4491) 10-21 20:55:28.461: E/ActivityThread(4526): at java.lang.reflect.Method.invokeNative(Native Method) 10-21 20:55:28.461: E/ActivityThread(4526): at java.lang.reflect.Method.invoke(Method.java:511) 10-21 20:55:28.461: E/ActivityThread(4526): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 10-21 20:55:28.461: E/ActivityThread(4526): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 10-21 20:55:28.461: E/ActivityThread(4526): at dalvik.system.NativeStart.main(Native Method)

    Read the article

  • Managing database connections in an Android Activity

    - by Daniel Lew
    I have an application with a ListActivity that uses a CursorAdapter as its adapter. The ListActivity opens the database and does the querying for the CursorAdapter, which is all well and good, but I am having issues with figuring out when to close both the Cursor and the SQLiteDatabase. The way things are handled right now, if the user finishes the activity, I close the database and the cursor. However, this still ends up with the DalvikVM warning me that I've left a database open - for example, if the user hits the "home" button (leaving the activity in the task's stack), rather than the "back" button. If I close them during pause and then re-query during resume, then I don't get any errors, but then a user cannot return to the list without it requerying (and thus losing the user's place in the list). By this I mean, the user can click on any item in the list and open a new activity based on it, but will often want to hit "back" afterwards and return to the same place on the list. If I requery, then I cannot return the user back to the correct spot. What is the proper way to handle this issue? I want the list to remain scrolled properly, but I don't want the VM to keep complaining about unclosed databases. Edit: Here's a general outline of how I handle the code at the moment: public class MyListActivity extends ListActivity { private Cursor mCursor; private CursorAdapter mAdapter; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new MyCursorAdapter(this); setListAdapter(mAdapter); } protected void onPause() { super.onPause(); if (isFinishing()) { mCursor.close(); } } protected void onDestroy() { super.onDestroy(); mCursor.close(); } private void updateQuery() { // If we had a cursor open before, close it. if (mCursor != null) { mCursor.close(); } MyDbHelper dbHelper = new MyDbHelper(this); SQLiteDatabase db = dbHelper.getReadableDatabase(); mCursor = db.query(...); mAdapter.changeCursor(mCursor); db.close(); } } updateQuery() can be called multiple times because the user can filter the results via menu items (I left this part out of the code, as the problem still occurs even if the user does no filtering). Again, the issue is that when I hit home I get leak errors. Yet, after going home, I can go back to the app and find my list again - cursor fully intact.

    Read the article

  • How to add image in ListView android

    - by Wawan Den Frastøtende
    i would like to add images on my list view, and i have this code package com.wilis.appmysql; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; //import android.util.Log; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class menulayanan extends ListActivity { /** Called when the activity is first created. */ public void onCreate(Bundle icicle) { super.onCreate(icicle); // Create an array of Strings, that will be put to our ListActivity String[] menulayanan = new String[] { "Berita Terbaru", "Info Item", "Customer Service", "Help","Exit"}; //Menset nilai array ke dalam list adapater sehingga data pada array akan dimunculkan dalam list this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,menulayanan)); } @Override /**method ini akan mengoveride method onListItemClick yang ada pada class List Activity * method ini akan dipanggil apabilai ada salah satu item dari list menu yang dipilih */ protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); // Get the item that was clicked // Menangkap nilai text yang dklik Object o = this.getListAdapter().getItem(position); String pilihan = o.toString(); // Menampilkan hasil pilihan menu dalam bentuk Toast tampilkanPilihan(pilihan); } /** * Tampilkan Activity sesuai dengan menu yang dipilih * */ protected void tampilkanPilihan(String pilihan) { try { //Intent digunakan untuk sebagai pengenal suatu activity Intent i = null; if (pilihan.equals("Berita Terbaru")) { i = new Intent(this, PraBayar.class); } else if (pilihan.equals("Info Item")) { i = new Intent(this, PascaBayar.class); } else if (pilihan.equals("Customer Service")) { i = new Intent(this, CustomerService.class); } else if (pilihan.equals("Help")) { i = new Intent(this, Help.class); } else if (pilihan.equals("Exit")) { finish(); } else { Toast.makeText(this,"Anda Memilih: " + pilihan + " , Actionnya belum dibuat", Toast.LENGTH_LONG).show(); } startActivity(i); } catch (Exception e) { e.printStackTrace(); } } } and i want to add different image per list, so i mean is i want to add a.png to "Berita Terbaru", b.png to "Info Item", c.png "Customer Service" , so how to do it? i was very confused about this, thanks before...

    Read the article

  • Design pattern for extending Android's activities?

    - by Carl
    While programming on Android, I end up writing a parent activity which is extended by several others. A bit like ListActivity. My parent activity extends Activity. if I intend to use a Map or a List, I can't use my parent activity as superclass - the child activity can only extend one activity obviously. As such I end up writing my parent activities with the same logic for Activity, ListActivity, MapActivity and so forth. What am I looking for is some sort of trait functionality/design pattern which would help in this case. Any suggestions?

    Read the article

  • Design patter for extending Android's activities?

    - by Carl
    While programming on Android, I end up writing a parent activity which is extended by several others. A bit like ListActivity. My parent activity extends Activity. if I intend to use a Map or a List, I can't use my parent activity as superclass - the child activity can only extend one activity obviously. As such I end up writing my parent activities with the same logic for Activity, ListActivity, MapActivity and so forth. What am I looking for is some sort of trait functionality/design pattern which would help in this case. Any suggestions?

    Read the article

  • Android custom ListView unable to click on items

    - by MattC
    So I have a custom ListView object. The list items have two textviews stacked on top of each other, plus a horizontal progress bar that I want to remain hidden until I actually do something. To the far right is a checkbox that I only want to display when the user needs to download updates to their database(s). When I disable the checkbox by setting the visibility to Visibility.GONE, I am able to click on the list items. When the checkbox is visible, I am unable to click on anything in the list except the checkboxes. I've done some searching but haven't found anything relevant to my current situation. I found this question but I'm using an overridden ArrayAdapter since I'm using ArrayLists to contain the list of databases internally. Do I just need to get the LinearLayout view and add an onClickListener like Tom did? I'm not sure. Here's the listview row layout XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/UpdateNameText" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1" android:textSize="18sp" android:gravity="center_vertical" /> <TextView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/UpdateStatusText" android:singleLine="true" android:ellipsize="marquee" /> <ProgressBar android:id="@+id/UpdateProgress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:indeterminateOnly="false" android:progressDrawable="@android:drawable/progress_horizontal" android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal" android:minHeight="10dip" android:maxHeight="10dip" /> </LinearLayout> <CheckBox android:text="" android:id="@+id/UpdateCheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> And here's the class that extends the ListActivity. Obviously it's still in development so forgive the things that are missing or might be left laying around: import java.util.List; import android.app.ListActivity; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.ListView; import android.widget.ProgressBar; import android.widget.TextView; import com.xxxx.android.R; import com.xxxx.android.DAO.AccountManager; import com.xxxx.android.model.UpdateItem; public class UpdateActivity extends ListActivity { AccountManager lookupDb; boolean allSelected; UpdateListAdapter list; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); lookupDb = new AccountManager(this); lookupDb.loadUpdates(); setContentView(R.layout.update); allSelected = false; list = new UpdateListAdapter(this, R.layout.update_row, lookupDb.getUpdateItems()); setListAdapter(list);

    Read the article

  • Looking for suggestions on how to reuse AlertDialogs to confirm actions of contextual menus on the items of an ActivityList

    - by Ozone
    I use a ListActivity to display a list of items. The user can long-press an item in the list to display a contextual menu. This menu contains among other things an option to delete the long-pressed item. When the user selects this option, a dialog pops up asking for confirmation of the deletion. Upon confirmation, the item is deleted from the list. I would like to reuse the AlertDialog as much as possible. My attempts at using onPrepareDialog(int, View, Bundle) have been defeated by the fact that the Bundle is not passed to the DialogInterface.OnClickListener. I end up having to recreate a listener on every invocation. I see several ways to solve this: recreate the dialog on every occasion (pros: simple, cons: wasteful) keep the DialogInterface.OnClickListener in a field on the ListActivity and keep the item to be deleted as a field of the listener. (pros: no memory waste, cons: need to manage state). Q: is this safe? have onPrepareDialog update the title, and bind new View.OnClickListeners on the buttons of the AlertDialog. (pros: limit waste, cons: new View.OnClickListener on every invocation). If DialogInterface.OnClickListener accepted a Bundle, I wouldn't have to jump through hoops to keep track of the item being deleted. This is not a blocker, but I would love to see an elegant solution. I would love to hear your suggestions :) Here is the code for option #1, if you want to play with this: public class Example extends ListActivity { private static final int CONFIRM_DELETE_DIALOG = 1; private static final String POSITION_KEY = "position"; private ArrayAdapter<String> mAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, new String[] { "one", "two" }); setListAdapter(mAdapter); registerForContextMenu(getListView()); } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); getMenuInflater().inflate(R.menu.my_lovely_menu, menu); } @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.delete_item: Bundle bundle = new Bundle(); bundle.putInt(POSITION_KEY, info.position); showDialog(CONFIRM_DELETE_DIALOG, bundle); return true; default: return super.onContextItemSelected(item); } } @Override protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { case CONFIRM_DELETE_DIALOG: final int position = args.getInt(POSITION_KEY); AlertDialog.Builder builder = new AlertDialog.Builder(); builder.setCancelable(false); builder.setTitle(String.format( getString(R.string.confirm_delete), mAdapter.getItem(position))); DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: mAdapter.remove(mAdapter.getItem(position)); // Dismiss the dialog to ensure OnDismissListeners are notified. dialog.dismiss(); break; case DialogInterface.BUTTON_NEGATIVE: // Cancel the dialog to ensure OnCancelListeners are notified. dialog.cancel(); break; } // Remove the dialog so it is re-created next time it is required. removeDialog(CONFIRM_DELETE_DIALOG); } }; builder.setPositiveButton(android.R.string.yes, listener); builder.setNegativeButton(android.R.string.no, listener); return builder.create(); default: return super.onCreateDialog(id, args); } } }

    Read the article

  • Change font size in ListView - Android/Eclipse

    - by Soren
    How can I change the font size in a ListView element? In my main.xml file, I have tried several different values in for android:textSize (pt,px,sp,dp) and nothing seems to change it. Here is what I have currently for the in my main.xml: <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/list" android:textColor="#ffffff" android:background="#000080" android:layout_width="fill_parent" android:layout_height="wrap_content" android:clickable="true" android:dividerHeight="1px" android:layout_marginTop="5px" android:textSize="8px"/> Here is my Java: package com.SorenWinslow.TriumphHistory; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class TriumphHistory extends ListActivity { String[] HistoryList; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ArrayAdapter<String> adapter; HistoryList = getResources().getStringArray(R.array.history); adapter = new ArrayAdapter<String> (this,android.R.layout.simple_list_item_1,HistoryList); setListAdapter(adapter); } }

    Read the article

  • Implementing a listview inside a sliding drawer with a listview already present

    - by Parker
    I have an app whose main class extends ListActivity: public class GUIPrototype extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Cursor c = managedQuery(People.CONTENT_URI, null, null, null, null); String[] from = new String[] {People.NAME}; int[] to = new int[] { R.id.row_entry }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,R.layout.drawer,c,from,to); setListAdapter(adapter); getListView().setTextFilterEnabled(true); } } I have a sliding drawer included in my XML, and I'm trying to get a separate listview to appear in the sliding drawer. I'm trying to populate the second listview using an inflater: View inflatedView = View.inflate(this, R.layout.main, null); ListView namesLV = (ListView) inflatedView.findViewById(R.id.content); String[] names2 = new String[] { "CS 345", "New Tag", "Untagged" }; ArrayAdapter<String> bb = new ArrayAdapter<String>(this, R.layout.main, R.id.row_entry, names2); namesLV.setAdapter(bb); This compiles, and runs, but the slidingdrawer is completely blank. My XML follows: <SlidingDrawer android:id="@+id/drawer" android:handle="@+id/handle" android:content="@+id/content" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="bottom"> <ImageView android:id="@id/handle" android:layout_width="48px" android:layout_height="48px" android:background="@drawable/icon"/> <ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@id/content"/> </SlidingDrawer> I feel like I'm missing a vital step. I haven't found any resources on my problem by Googling, so any help would be greatly appreciated.

    Read the article

  • listView dynamic add item

    - by pengwang
    hello,I used ListView to dynamic add item,but there is a problem about not Smooth add. there are textView and button in my listActivity,Iwant to Press button ,then textView"s text can auto add to listView,but i Pressed button ,it donot work,unless after i enter content , press "OK"Key ,then Pressed button ,textView"s text can auto add to listView. I donot know why. if I continuous Pressed button ,as3 times, then press "Ok"Key ,the content auto add list View but 3 times. public class DynamicListItems extends ListActivity { private static final String ITEM_KEY = "key"; ArrayList<HashMap<String, String>> list= new ArrayList<HashMap<String, String>>(); private SimpleAdapter adapter; private EditText newValue;@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dynamic_list); newValue = (EditText) findViewById(R.id.new_value_field); setListAdapter(new SimpleAdapter(this, list, R.layout.row, new String[] { ITEM_KEY }, new int[] { R.id.list_value })); ((ImageButton) findViewById(R.id.button)).setOnClickListener(getBtnClickListener()); } private OnClickListener getBtnClickListener() { return new OnClickListener() { public void onClick(View view) { try { HashMap<String, String> item = new HashMap<String, String>(); item.put(ITEM_KEY, newValue.getText().toString()); list.add(item); adapter.notifyDataSetChanged(); } catch (NullPointerException e) { Log.i("[Dynamic Items]", "Tried to add null value"); } } }; }} my another question is how to dynamic delete the item,which event i need to used,could you give me some directions or Code snippets? dynamic_list.xml only contains listView ,button,textView row.xml contains TextView . i amm sorry i donot edit code together.

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >