Android :: How To Dismiss Dialog After Clicking Any Item?

Mar 15, 2009

From the reference of SDK, AlertDialog information as below. I want to create a dialog but I don't want to have any buttons in the dialog, then I hope to dismiss the dialog after I click any item in the dialog, how should I dismiss the dialog ? When the user click the "back" button, it will dismiss the dialog. So I need to send the key message in hard code? Is there any other way?
public AlertDialog.Builder<http://developer.android.com/reference/android/app/AlertDialog.Builde...>
setSingleChoiceItems (CharSequence[]<http://developer.android.com/reference/java/lang/CharSequence.html>items,
int checkedItem, DialogInterface.OnClickListener<http://developer.android.com/reference/android/content/DialogInterfac...>listener)

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for the checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog. Parameters items the items to be displayed. Checked Item specifies which item is checked. If -1 no items are checked. Listener notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss.

Android :: How to dismiss Dialog after Clicking Any Item?


Android :: Make DatePickerDialog Not Dismiss After Clicking Set Button?

Apr 25, 2010

Is there any way to make DatePickerDialog not dismiss after clicking set button ?

View 2 Replies View Related

Android :: Right Way To Dismiss Dialog

Dec 17, 2009

I am trying to use a managed dialog. I noticed that after the first time I display it, subsequent creations don't actually make a new instance of the dialog, they just seem to reuse the first one. If I want to stop that, and get a brand new instance on every call, is this the right way to do it?:

@Override
protected Dialog onCreateDialog(int id) { switch (id) { case MY_DIALOG_ID:
MyDlg dlg = new MyDlg(this);
dlg.setOnDismissListener(new OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
removeDialog(MY_DIALOG_ID);
} } );
return dlg;
} return null;
}

So I guess the removeDialog() call does the trick, but my onDismiss() handler should be called in every instance of the dialog being killed, right (like Dialog.cancel(), Dialog.dismiss(), hitting the back key)?

View 1 Replies View Related

Android :: How To Dismiss Dialog?

Aug 5, 2010

AlertDialog.Builder fpdialog = new AlertDialog.Builder(context);
ListView fpathlist = new ListView(context);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(context,android.R.layout.simple_expandable_list_item_1, fpathdata());
OnItemClickListener listener = new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, final int position, long arg3) {
// TODO Auto-generated method stub for (int i=0;i<=position;i++) {
if (i==position) { CharSequence[] pathString ;
final AlertDialog.Builder pathlist = new AlertDialog.Builder(context);
pathlist.setTitle;
pathlist.setItems(pathString, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Here I want to dismiss the fpdialog } } );
pathlist.show();
} } } };
fpathlist.setOnItemClickListener(listener);
fpathlist.setAdapter(adapter);
fpdialog.setView(fpathlist);
fpdialog.show();

View 2 Replies View Related

Android :: Dismiss Failed In Dialog

Aug 12, 2010

I would like to create my own DateTimePicker Dialog. Therefor I build a layout that I use in my Dialog. My Dialog starts when I click on a Button. When the Dialog opens you can set date and time data. There is still a Button to close the Dialog. This Button calls Dialog.dismiss(). But it fails. Here is some code. Can someone tell me, what I do wrong?

public class CreateActivity extends Activity{ private TextView mDateTimeDisplay;
private Dialog dateTimePicker;
private int mYear; private int mMonth; private int mDay; private int mHour; private int mMinute;
static final int DATE_DIALOG_ID = 0;
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(de.android.todo.R.layout.create);
//http://babukuma.com/2010/01/android-custom-component- datetimepicker_29.html
mDateTimeDisplay = (TextView) findViewById(R.id.dateTimeDisplay);
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR); mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH); mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE); dateTimePicker = new Dialog(this);
dateTimePicker.setContentView(R.layout.datetimepicker);
dateTimePicker.setTitle("DateTimePicker");
dateTimePicker.setCancelable(true);
DatePicker dp = (DatePicker) dateTimePicker.findViewById(R.id.datePicker);
dp.init(mYear, mMonth, mMonth, onDateChangedListener);
TimePicker tp = (TimePicker) dateTimePicker.findViewById(R.id.timePicker);
tp.setIs24HourView(true);
tp.setOnTimeChangedListener(onTimeChangedListener);
// display the current date updateDisplay();
} public void onClickShowMyDialog(final View v){ showDialog(DATE_DIALOG_ID);
} public void onClickCloseDialog(final View v){ dateTimePicker.dismiss();
} @Override protected Dialog onCreateDialog(int id) { switch (id) {
case DATE_DIALOG_ID: return dateTimePicker;
} return null;
}

View 2 Replies View Related

Android :: How To Dismiss Custom Dialog?

May 13, 2010

I'm trying to make a custom dialog to show a view in this dialog. This is the Builder code:

//Getting the layout LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog_simple,(ViewGroup) findViewById(R.id.rlDialogSimple));
//Change Text and on click
TextView tvDialogSimple = (TextView) layout.findViewById(R.id.tvDialogSimple);
tvDialogSimple.setText(R.string.avisoComprobar);
Button btDialogSimple = (Button) layout.findViewById(R.id.btDialogSimple);
btDialogSimple.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//Do some stuff
//Here I want to close the dialog
} } );

AlertDialog.Builder builder = new AlertDialog.Builder(AcPanelEditor.this);
builder.setView(layout);
AlertDialog alert = builder.create();
alert.show();

So, I want to dismiss the dialog in the onClick of btDialogSimple. How I can do it? I don't know how to call the dismiss method from inside a onclicklistener. My buttons have a custom layout, so I don't want to make a builder.setPositiveButton.

View 1 Replies View Related

Android :: How To Dismiss Spinner Dialog Automatically?

Jul 30, 2009

I am sure that everybody can easily recur the problem I am facing. There is a Spinner in the view, which includes a few entries. When I click the Spinner, it pops up a dialog so user can choose an entry. All these are very normal and you can find such things in SDK's API demo. The problem is: when the dialog is still on focus, if you change the phone's orientation, an exception will be thrown. Something like this:
07-30 20:46:03.727: ERROR/WindowManager(416): Activity com.client.CommandList has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@43116318 that was originally added here 07-30 20:46:03.727: ERROR/WindowManager(416): android.view.WindowLeaked:
Activity com.client.CommandList has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView@43116318 that was originally added here
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewRoot.<init ViewRoot.java:214)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.Window$LocalWindowManager.addView(Window.java:392)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.app.Dialog.show(Dialog.java:231)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.app.AlertDialog$Builder.show(AlertDialog.java:802)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.widget.Spinner.performClick(Spinner.java:247)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.View.onTouchEvent(View.java:3828)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.View.dispatchTouchEvent(View.java:3368)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:831)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
07-30 20:46:03.727: ERROR/WindowManager(416): at com.android.internal.policy.impl.PhoneWindow $DecorView.superDispatchTouchEvent(PhoneWindow.java:1707)
07-30 20:46:03.727: ERROR/WindowManager(416): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1197) 07-30 20:46:03.727: ERROR/WindowManager(416): at android.app.Activity.dispatchTouchEvent(Activity.java:1993)
07-30 20:46:03.727: ERROR/WindowManager(416): at com.android.internal.policy.impl.PhoneWindow $DecorView.dispatchTouchEvent(PhoneWindow.java:1691)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.view.ViewRoot.handleMessage(ViewRoot.java:1525)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.os.Looper.loop(Looper.java:123)
07-30 20:46:03.727: ERROR/WindowManager(416): at android.app.ActivityThread.main(ActivityThread.java:3948)
07-30 20:46:03.727: ERROR/WindowManager(416): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 20:46:03.727: ERROR/WindowManager(416): at java.lang.reflect.Method.invoke(Method.java:521)
07-30 20:46:03.727: ERROR/WindowManager(416): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:782)
07-30 20:46:03.727: ERROR/WindowManager(416): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-30 20:46:03.727: ERROR/WindowManager(416): at dalvik.system.NativeStart.main(Native Method)

View 4 Replies View Related

Android :: Unable To Dismiss Progress Dialog

Nov 5, 2010

I've got a progress dialog that I'm unable to dismiss and I can't figure out why. The first time through the code, it shows the dialog and dismisses it perfectly. The second time through it fails to dismiss. There is no error in the logcat and no exceptions are thrown, but the dialog remains on the screen.

If I run the code a third time, while the dialog is on the screen, a window leak exception is shown in the logcat when the code attempts to show the dialog, which is pretty much what you'd expect. The showDialog is called right before I call the execute method of an AsyncTask and the dismissDialog is called in the onPostExecute method of that AsyncTask.

View 3 Replies View Related

Android :: Dismiss Dialog With Custom Layout

Aug 16, 2010

I have a dialog with a custom layout, and I try to close it when I press a button:
private void showAboutDialog() {
dialog = new Dialog(MainMenu.this);
dialog.setContentView(R.layout.about_dialog);
dialog.setCancelable(true);
dialog.setTitle(R.string.about_title);
dialog.show();

LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.layout_root));
Button closeButton = (Button) layout.findViewById(R.id.about_close_button);
closeButton.setOnClickListener(new Button.OnClickListener() { public void onClick(View view) { dialog.dismiss();
} } );
}
But it doesn't work.

View 1 Replies View Related

Android :: How To Dismiss Single Select Dialog?

Mar 14, 2009

Thanks for your reminding me of that. JBQ. From the reference of SDK, AlertDialog information as below. I want to create a dialog but I don't want to have any buttons in the dialog, then I hope to dismiss the dialog after i click any item in the dialog, how should I dismiss the dialog? When the user click the "back" button, it will dismiss the dialog. So I need to send the key message in hard code? is there any other way?

public AlertDialog.Builder<http://developer.android.com/reference/android/app/AlertDialog.Builde...>
setSingleChoiceItems (CharSequence[]<http://developer.android.com/reference/java/lang/CharSequence.html>items, int checkedItem, DialogInterface.OnClickListener
<http://developer.android.com/reference/android/content/DialogInterfac...>listener)

Set a list of items to be displayed in the dialog as the content, you will be notified of the selected item via the supplied listener. The list will have a check mark displayed to the right of the text for the checked item. Clicking on an item in the list will not dismiss the dialog. Clicking on a button will dismiss the dialog. Parameters items the items to be displayed. Checked Item specifies which item is checked. If -1 no items are checked. listener notified when an item on the list is clicked. The dialog will not be dismissed when an item is clicked. It will only be dismissed if clicked on a button, if no buttons are supplied it's up to the user to dismiss the dialog.

View 5 Replies View Related

Android :: Preventing Dialog Auto-Dismiss On Button Click

Mar 20, 2010

Is there any way (the best way) to avoid this happening? I am using a ProgressDialog which has one cancel button. On clicking the cancel button I want to disable the cancel button and change the message to "Canceling...". That bit's easy. Only once the cancellation has been fully processed do I want to dismiss the dialog. The only way I can think of is to use a custom layout but I would rather keep the default dialog look and feel (rather than trying to simulate it with my own code).

View 4 Replies View Related

Android :: How To Make My Progress Dialog Dismiss After Webview Loaded?

Jul 19, 2010

What do I need to my code to make the dialog dismiss() after the webview is loaded?

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new homeClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setPluginsEnabled(true);
webview.loadUrl("http://google.com");
ProgressDialog pd = ProgressDialog.show(Home.this, "", "Loading. Please wait...", true);
}
I've tried
public void onPageFinshed(WebView view, String url){ pd.dismiss();
}
Didn't work.

View 3 Replies View Related

Android : Progress Dialog Went Back To First View Called It When Dismiss

Nov 3, 2009

I have a weird problem on progress dialog: I have 2 views: Login View and say, Display View. In Login View, when I click the 'Login' button, a progress dialog is created (new ProgressDialog(...)), shown and stored in a variable 'mProgressDialog'. After login, the dialog is dismissed and some information are displayed in Display View (Login View hides). Now I want to display another progress dialog when 'Update' button is clicked and when the update is done, dismiss the dialog and display new information. So I use: the Display View for a blink and then shows the Login View. I tried to change the view etc. but same problem happens over and over again. So I am thinking it might because one activity can only be assigned to ONE progress dialog and no matter how you re-create it you still get the same progress dialog. And the dialog is linked to a certain view which will be shown automatically when the dialog dismisses.

View 8 Replies View Related

Android :: Generic Task Manager Class For Application / No Dismiss Dialog

Nov 15, 2010

I have a class which extends AsyncTask, which is intended to serve as a generic task manager class for my application. The strange behavior is that the progress dialog shows up, but is never dismissed. I am sure that onPostExecute() gets called for every task instance, as any Log.d("","") statements fire if placed in here, even the Toast messages show up from within this method, but I am not able to dismiss the static dialog. I understand that AsyncTask(s) have access to UI thread at only 2 places [onPreExecute() and onPostExecute()], so I think trying to dismiss the dialog in runOnUiThread() is unnecessary. All calls to executeTask() are made from different onCreate() methods of different activities that need to fetch some data over network before populating some of their UI elements, and I always pass the current activity's context to the tasks. As I do not switch activities until after the related tasks are completed, I believe the activity context objects are still valid (am I wrong to have assumed this???) I have never found any of them to be null while debugging.

Could this be a timing issue? I have also observed that most of the times DDMS shows all tasks get completed before the activity is displayed. If I use new Handler().postDelayed(runnable_which_calls_these_tasks,10); in the onCreate(), and add delaying code in foo_X(), the activities are displayed without any delay, but the dialog will just not dismiss(). I have read through quite a number of articles on this issue but am still not able to figure out exactly where am I going wrong. I do not want to define each task as private inner class Task1 extends AsyncTask<> in all of my activity classes and I would not want to (unless this is the only solution) load my application object with all activity references either as mentioned in this discussion: Is AsyncTask really massively flawed or am I just missing something?. I have spent a week on this and am absolutely clueless :( It would be great if someone can guide me, and let me know what am I missing. Following is the class definition: [I've removed some irrelevant application specific code for clarity]

public class NetworkTask extends AsyncTask<Void, Integer, Boolean> {
private Context UIcontext;
private int operationType;
private static ProgressDialog dialog;
private static int taskCount;
private NetworkTask(int operationType Context context){ this.UIcontext = context;
this.operationType = operationType;
if (taskCount++ == 0) dialog = ProgressDialog.show(context,"","Loading...");
}

public static Boolean executeTask(int operationType, Context context) { return new NetworkTask(operationType, context).execute().get();
} @Override protected void onPreExecute(){ super.onPreExecute();
if (taskCount == 1) dialog.show();
} @Override protected Boolean doInBackground(Void... arg0) { switch(operationType){ case TYPE_1: foo1();
break; case TYPE_2: foo2(); break;
case TYPE_3 foo3(); break; case TYPE_4: foo4(); break;
} @Override protected void onPostExecute(Boolean result) { super.onPostExecute(result);
taskCount--;
if (dialog.isShowing() && taskCount == 0){ dialog.dismiss();
}else { Toast.makeText(UIcontext, "Task#"+ operationType+", m done, but there are "+taskCount+" more", 5).show();
} } }

View 1 Replies View Related

Android : Change Item In Listview After Clicking?

Apr 10, 2010

I've created a rather complex layout for listview rows where only the first line is visible (the rest use android:visibility="hidden"). When an item is selected, I want all the invisible objects to appear (selected.setVisibility(1)) - checking first if I have to hide again the previous selection.

Here's the (simplified) code..

The problem is that this only retrieves the invisible items in the first Listview row. What's the way to access ListView rows and change 'em?

View 4 Replies View Related

Android :: How To Display Menu Icons After Clicking More Item?

Sep 13, 2010

if I have an Options menu in Android that has more than 6 items, Android adds a More item that shows the other hidden items, AS text!But I want the More button to display the extra items both in their text AND icon, how do I do that?

View 1 Replies View Related

Android :: Prevent Context Menu From Closing On Clicking Item

Feb 25, 2010

If I have a checkable item in a Context Menu or ordianry Menu, how do I prevent the menu from closing when the item is selected?

View 2 Replies View Related

Android :: Standard Selection Color When Clicking On A List Item

Mar 11, 2009

I'd like to use the standard selection color when clicking on a list item. Where do I get it from?

View 3 Replies View Related

Android : Cancel A Dialog By Clicking On It - No Buttons?

Apr 8, 2010

I create my dialog like this code...

The suer can now cancel the notification popup message by clicking outside the box. But how do I allow the user to cancel the dialog by touching on the dialog?

View 3 Replies View Related

Android :: Get Custom Dialog Activity While Clicking On Listview In Droid?

Dec 12, 2009

How to get custom dialog activity while clicking on listview in android?

View 1 Replies View Related

Android :: Open A Custom Dialog When Clicking On A Listview Entry

Jun 21, 2010

I would like to open a custom dialog when someone clicks on a listview entry. That dialog will need to know the text that was clicked on in order to display additional information on that particular entry. Can anyone point me in the right direction on how to accomplish that?

View 1 Replies View Related

Android :: Android - Dismiss Dialog Method Not Working

May 21, 2009

I am using the showDialog and dismissDialog methods to show progress dialogs in my app. Moved from creating the dialog and calling show() on it to using this in order to save state when changing orientation. But when I change the orientation from portrait->landscape->portrait, the dismissDialog no longer dismisses the dialog. The dialog stay there all the time and I need to press the back button for it to disappear.

To overcome this issue, I tried adding a removeDialog in onDestroy so that the dialog is not created/displayed twice and before orientation change, the dialog is removed. Tried adding log statements and see what happens:

05-21 12:35:14.064: DEBUG/MyClass(193): callingShowDialog
05-21 12:35:14.064: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:15.385: DEBUG/MyClass(193): onSaveInstanceState
05-21 12:35:15.415: DEBUG/MyClass(193): onDestroy

05-21 12:35:15.585: DEBUG/MyClass(193): callingShowDialog
05-21 12:35:15.585: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:15.715: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:17.214: DEBUG/MyClass(193): onSaveInstanceState
05-21 12:35:17.214: DEBUG/MyClass(193): onDestroy
05-21 12:35:17.275: ERROR/WindowManager(193): android.view.WindowLeaked: Activity com.android.MyClass has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43362088 that was originally added here
05-21 12:35:17.395: DEBUG/MyClass(193): callingShowDialog
05-21 12:35:17.395: DEBUG/MyClass(193): onCreareDialog
05-21 12:35:17.475: DEBUG/MyClass(193): onCreareDialog

If we see here, initially when the activity is displayed, the onCreateDialog is called once and on changing the orientation, onSaveInstanceState and onDestroy are called. But after that, onCreateDialog is called twice (once by a call to showDialog which I make, but why the 2nd time?) and this happens every time I change the orientation hence forth.

View 5 Replies View Related

Android :: Dialog Dismiss / Cancel Handling (Android)

Nov 19, 2009

I never look forward to handling Android dialogs, maybe someone can point me to a better way of doing it than i'm doing right now. Say I have a dialog which has one text field in it, and OK and Cancel buttons. i make the dialog with AlertDialog.Builder, and set click listeners on the buttons and dismiss listener on the dialog. When the dismiss listener fires, can I tell which button caused the dismiss?

I don't see how, so in the click listener, I set a member flag according to which button was clicked. Then in the dismiss listener, I then check the flag to see whether to proceed or not. Arather backward process. Am I missing something? The other issue I have with Android's dialogs is that if the contents fail validation and the dialog needs to be re-presented, I have to re-show it in the dismiss listener. In every other environment known to man, dialogs are (somewhat) modal, so the dialog stays up unless expressly dismissed by code. IMHO, the latter makes more sense.

View 10 Replies View Related

Android :: Dismiss Android Preferences Dialog On Keyboard

Mar 15, 2010

I would like to be able to close the editpreference dialog (as shown here http://twitpic.com/18ttdp) by pressing the 'Done' button on the keyboard. Currently, pressing 'Done' just dismisses the keyboard but leaves the dialog. In other parts of my application I use code similar to the following to intercept the 'Done' key press and execute actions in my activity:

text.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
if (actionId == EditorInfo.IME_ACTION_DONE) {
//do stuff here return true;
} return false;
} } );

However, I am unsure of how to do achieve this same effect in my preference activity or layout XML.

View 2 Replies View Related

Highlight Selected Item Background After Clicking Back Button

Apr 18, 2013

I have to develop one android application.

Here is the scenario:There are many images in a linearlayout. When selected, the layout should be displayed with another(gradient_bg_hover.xml) background. This works well now.

Now, I would like that when I open a new activity and come back to this one, the last selected layout should still be the highlighted one (with the (gradient_bg_hover.xml) background).

Now i have used below code for highlighting the image when pressed:

[HIGH]
LinearLayout ar = new LinearLayout(this);
ar.setOrientation(LinearLayout.VERTICAL);
ar.setPadding(3, 3, 3, 3);
ar.setLayoutParams(artiLayoutParams);
ar.setGravity(Gravity.CENTER);
ar.setBackgroundColor(Color.parseColor("#666666")) ;

[Code]...

In OnClick function i have wrote the below code:

[HIGH]
private OnClickListener mArticleClick = new OnClickListener()
{
@Override
public void onClick ( View v )
{
int object = v.getId();
v.setSelected(true);

[Code]...

Here i have to clicked one item means it is go to next activity.afterthat i have clicked back button means the selected item is stay on highlighted with another background.afterthat i have selected another item means its go to next activity.now i have to click back button means these item only highlight with background....but the pervious item also highlighted....

I wish to need the o/p like :

The last selected item only highlighted after click the back button...

So i have used sharedpreferences :

I have declared int prevPosition = -1; globally...

[HIGH]
ar = new LinearLayout(this);
ar.setOrientation(LinearLayout.VERTICAL);
ar.setPadding(3, 3, 3, 3);
ar.setLayoutParams(artiLayoutParams);
ar.setGravity(Gravity.CENTER);

[Code]...

In Onclick method:

[HIGH]
private OnClickListener mArticleClick = new OnClickListener()
{
@Override
public void onClick ( View v )
{
int object = v.getId();

[Code]...

But my background color is not staying after press the back button...

View 1 Replies View Related

Android :: Add Icon In Alert Dialog Before Each Item?

Oct 13, 2010

i am using alert dialog with code below now i want to put image before each text for example email icon then text Email, facebook icon then text Facebook etc.. in alert dialog. using following code please guide how to add icon before each text value?

final CharSequence[] items = { "Email",
"Facebook","Twitter","LinkedIn"};
AlertDialog.Builder builder = new AlertDialog.Builder(More.this);
builder.setTitle("Share Appliction");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {...................

View 1 Replies View Related

Android :: Can I Create Dialog With Each Item Being Label And Then Checkbox

Jul 16, 2010

How can I create a dialog with each dialog item being a label and then a checkbox?

And when user click 'ok' to the dialog, I can tell in my code which on of the dialog item has been checked?

View 2 Replies View Related

Android :: Menu Item "info" To Create A Custom Dialog?

Mar 28, 2010

I want my menu item "info" to create a custom dialog. Yet i appear to to be having trouble:

This is in my main java file:

CODE:..............

View 10 Replies View Related

Android :: Click In List View Item Changes Status Of Elements Inside Item?

Apr 9, 2010

I don't know exactly how to explain this problem, but I'll try. I have a ListView with several items. Each item has inside a TextView and two ImageView. I want the ImageView change when I click on them, and I want to open a context menu when I press for a long time into the ListView item.For the ImageView, everything works properly. For the whole item, I can show the context menu after a long press, but my problem is that the ImageView changes as well when I am pressing the TextView, for example.I hope you understand my problem. I think that all the children of a view are affected by an event in the parent, but I am not sure.

View 2 Replies View Related

Android :: How To Scroll Up When Choose Some Item At Item List?

Nov 20, 2010

I jave a list of item (linearlayout inside a scrollview where i add buttons vertically to linearlayout dynamically from the java code)i need when i click on one button the item moves up (scroll up) , to make the item at the first of the screen

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved