Launching a dialog from preferences?

by jsdf » Sun, 08 Mar 2009 07:41:38 GMT

Sponsored Links
Is there a way to launch a dialog (say, the dialog I show to users the
first time they launch the app) from a preferences entry?

I don't see any examples doing this in the API Demos, nor have I seen
it out in the wild.

I do see a class called DialogPreference, but this doesn't seem to be
what I want.


Launching a dialog from preferences?

by Mark Murphy » Sun, 08 Mar 2009 07:57:41 GMT


If you just need it from the preferences activity, you could always put
it as an option menu choice.

Mark Murphy (a Commons Guy) 

Android Training on the Ranch! -- Mar 16-20, 2009 


Sponsored Links

Launching a dialog from preferences?

by Stoyan Damov » Mon, 09 Mar 2009 07:07:41 GMT

 Search this list for SeekBarPreference. Marc Tan (thanks again Marc)
shared an example of a DialogPreference subclass which displays a seek
bar. You can use it as a starting point to create your own dialog and
stick whatever you need in it.



Other Threads

1. Updating UI in one activity from another activity

I have an activity (Activity A) that simply shows a list that a user
can pick from.

In a separate activity (Activity B) this list can be manipulated (ie:
add, delete).  What's the best way to have an interaction in Activity
B tell Activity A to refresh its list so when the user returns to
Activity A the list is up to date?

Is this a situation where a BroadcastReceiver makes sense?  Should the
list be managed by a service instead?  Other thoughts?


2. List Items and List Activities


I am having problems figuring out how to get some information from a
list I've created. I'm trying to retrieve the _ID, which is the
primary key of my database so that I can use it as a parameter to pass
to either a method to delete or to another class to do an update.
My code is below any help will be much appreciated

package inc1.proto2;

import static android.provider.BaseColumns._ID;
import static inc1.proto2.Constants.TABLE_NAME;
import static inc1.proto2.Constants.TITLE;
import static inc1.proto2.Constants.TIME;
import static inc1.proto2.Constants.STARTTIME;
import static inc1.proto2.Constants.ENDTIME;
import static inc1.proto2.Constants.REMINDERTIME;
import inc1.proto2.EventsData;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.Toast;

public class Read extends ListActivity
        private static String[] FROM = { _ID, TIME, TITLE, STARTTIME,
        private static String ORDER_BY = _ID + " ASC";
        private static int[] TO = {,,,,
        private EventsData events;

        public void onCreate(Bundle icicle)
                events = new EventsData(this);
                        Cursor cursor = getEvents();

        private Cursor getEvents()
                // Perform a managed query. The Activity will handle closing
            // and re-querying the cursor when needed.
            SQLiteDatabase db = events.getReadableDatabase();
            Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null,
                                        null, ORDER_BY);
            return cursor;

        private void showEvents(Cursor cursor)
                // Set up data binding
            SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
cursor, FROM, TO);

        protected void onListItemClick(ListView l, View v, int position, long
                super.onListItemClick(l, v, position, id);

                final String testPosID  = String.valueOf(l.getId());

                new AlertDialog.Builder(this)
        new DialogInterface.OnClickListener()
                public void onClick(DialogInterface dialoginterface, int i)
                        // 0 = Update 1 = Delete

                        if (i == 0){

                                " UPDATE",Toast.LENGTH_LONG).show();

                        if (i == 1){



3. Seg fault on Emulator startup?

4. WEP connection problem

5. Big difficult to develop in Android :( (I'm italian)

6. String to spannable

7. Download a file from a URL extremely slow, am I doing it right?