Launching a dialog from preferences?

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


Sponsored Links
 Hi,
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.

Thanks.
--~--~---------~--~----~------------~-------~--~----~



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)
 http://commonsware.com 

Android Training on the Ranch! -- Mar 16-20, 2009
 http://www.bignerdranch.com/schedule.shtml 

--~--~---------~--~----~------------~-------~--~----~


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.

Cheers




--~--~---------~--~----~------------~-------~--~----~



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

Hi,

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.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.UrlQuerySanitizer.ValueSanitizer;
import android.os.Bundle;
import android.widget.Toast;

public class Read extends ListActivity
{
        private static String[] FROM = { _ID, TIME, TITLE, STARTTIME,
ENDTIME, REMINDERTIME };
        private static String ORDER_BY = _ID + " ASC";
        private static int[] TO = { R.id.rowid, R.id.time, R.id.title,
R.id.starttime,
                                                           R.id.endtime, 
R.id.reminder};
        private EventsData events;

        public void onCreate(Bundle icicle)
        {
                super.onCreate(icicle);
                setContentView(R.layout.read);
                events = new EventsData(this);
                try
                {
                        Cursor cursor = getEvents();
                        showEvents(cursor);
                }
                finally
                {
                        events.close();
                }
        }

        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);
            startManagingCursor(cursor);
            return cursor;
        }

        private void showEvents(Cursor cursor)
        {
                // Set up data binding
            SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
                                                                R.layout.item, 
cursor, FROM, TO);
           setListAdapter(adapter);
        }

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

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

                new AlertDialog.Builder(this)
        .setTitle(R.string.manage_title)
        .setItems(R.array.UDOptions,
        new DialogInterface.OnClickListener()
        {
                public void onClick(DialogInterface dialoginterface, int i)
                {
                        // 0 = Update 1 = Delete

                        if (i == 0){

                                Toast.makeText(Read.this,
                                " UPDATE",Toast.LENGTH_LONG).show();
                        }

                        if (i == 1){
                                Toast.makeText(Read.this,
                        testPosID,Toast.LENGTH_LONG).show();
                        }

                }
        })
        .show();
        }
}

-- 

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?