Toast View

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Toast View

Postby javai » Mon Sep 21, 2009 11:38 pm

I have a ListView with many items,

I want to have a popup like item, that will display some text associated with listView item.

What should I use? Toast?

Ideally I dont want to have a new Activity, which would constitue a new view.

Cheers
javai
Freshman
Freshman
 
Posts: 8
Joined: Sun Sep 13, 2009 11:52 pm

Top

Postby javai » Mon Sep 21, 2009 11:39 pm

If someone could also post some examples (both pictures and code) that would be good..

:-)
javai
Freshman
Freshman
 
Posts: 8
Joined: Sun Sep 13, 2009 11:52 pm

Postby yaj786 » Tue Sep 22, 2009 12:01 am

Use the alertdialog object:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. new AlertDialog.Builder(YourActivity.this)
  3.  
  4. .setMessage("Here is the info")
  5.  
  6. .setPositiveButton("Yes", new DialogInterface.OnClickListener(){
  7.  
  8.         @Override
  9.  
  10.          public void onClick(DialogInterface dialog, int which)
  11.  
  12.         {
  13.  
  14.                 //do stuff here
  15.  
  16.         }
  17.  
  18. })
  19.  
  20. .show();
  21.  
  22.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
yaj786
Developer
Developer
 
Posts: 33
Joined: Fri Jul 10, 2009 7:37 am

AlertDialog, custom View

Postby javai » Sat Sep 26, 2009 1:26 am

Heeyyy thanks for this awesome example.

I did some reading around this - What i want to do is customoise my view for the alert dialog..

I keep on getting a null pointer exception

Here's my code.

Code: Select all
View xt =  findViewById(R.layout.test);
      
      TextView tc  = (TextView) findViewById(R.id.test1);
      
      tc.setBackgroundColor(Color.DKGRAY);
      
      
      tc.setText("Hahahah");
      new AlertDialog.Builder(this).setView(xt).create().show();


tc is an element inside xt.

Any ideas/examples how I could customise my view for my AlertDialog?

Cheers
javai
Freshman
Freshman
 
Posts: 8
Joined: Sun Sep 13, 2009 11:52 pm

Postby Emmanuel7 » Sun Sep 27, 2009 5:39 pm

I'm not sure I understand what you wanted...

But if you wanted to have a customised alertDialog, here is how to do it :
(at least, it is how I did it in WordProspector)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. LayoutInflater factory = LayoutInflater.from(this);
  2.  
  3. final EditText editEntryView = (EditText) factory.inflate( R.layout.misc_stuff, null);
  4.  
  5. AlertDialog CurDialog = new AlertDialog.Builder(this)
  6.  
  7.                                         .setTitle(getResources().getString( R.string.EnterName ) )
  8.  
  9.                                         .setView(editEntryView)
  10.  
  11.                                         .setPositiveButton("OK", new DialogInterface.OnClickListener() {
  12.  
  13. ...
  14.  
  15. ...
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Hope it helps,
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby javai » Wed Oct 07, 2009 11:20 pm

Thanks for this emanuelle. :)
javai
Freshman
Freshman
 
Posts: 8
Joined: Sun Sep 13, 2009 11:52 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests