Dialog+Image+Text?

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

Dialog+Image+Text?

Postby bavarol » Wed Aug 06, 2008 9:37 am

Hi,
I don't know how I can show an image with a text as Dialog or something like this.

I can just show Text.

Please help
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Top

Postby cgreen » Wed Aug 06, 2008 12:57 pm

i've no idea about including an image, but this is the first step for a dialog-popup:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  private void showDialog(String title, String text)
  2.  
  3.   {
  4.  
  5.     final Dialog dia = new Dialog(this);
  6.  
  7.     dia.setContentView(R.layout.msgdialog);
  8.  
  9.     dia.setTitle(title);
  10.  
  11.     Button okbutton = (Button) dia.findViewById(R.id.okbutton);
  12.  
  13.     TextView textField = (TextView) dia.findViewById(R.id.msg);
  14.  
  15.     textField.setTextSize(12f);
  16.  
  17.     textField.setBackgroundColor(Color.BLACK);
  18.  
  19.     textField.setTextColor(Color.WHITE);
  20.  
  21.     textField.setText(text);
  22.  
  23.     okbutton.setOnClickListener(new View.OnClickListener()
  24.  
  25.     {
  26.  
  27.       public void onClick(View view)
  28.  
  29.       {
  30.  
  31.         dia.dismiss();
  32.  
  33.       }
  34.  
  35.     });
  36.  
  37.     dia.show();
  38.  
  39.   }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


maybe this helps creating a dialog with text.

i guess an image could be reference with the R.drawable.IMAGENAME, but i didn't try to display any yet.
User avatar
cgreen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Wed Jul 16, 2008 10:16 am

Postby bavarol » Fri Aug 08, 2008 11:21 am

cgreen wrote:i've no idea about including an image, but this is the first step for a dialog-popup:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  private void showDialog(String title, String text)
  2.   {
  3.     final Dialog dia = new Dialog(this);
  4.     dia.setContentView(R.layout.msgdialog);
  5.     dia.setTitle(title);
  6.     Button okbutton = (Button) dia.findViewById(R.id.okbutton);
  7.     TextView textField = (TextView) dia.findViewById(R.id.msg);
  8.     textField.setTextSize(12f);
  9.     textField.setBackgroundColor(Color.BLACK);
  10.     textField.setTextColor(Color.WHITE);
  11.     textField.setText(text);
  12.     okbutton.setOnClickListener(new View.OnClickListener()
  13.     {
  14.       public void onClick(View view)
  15.       {
  16.         dia.dismiss();
  17.       }
  18.     });
  19.     dia.show();
  20.   }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


maybe this helps creating a dialog with text.

i guess an image could be reference with the R.drawable.IMAGENAME, but i didn't try to display any yet.

Thx a lot, I thought, I should develop one more Activity.
About a picture, I can tell you, it's easy, I can show a picture (by its path) with its description

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.      
  2.  
  3. ...      
  4.  
  5.             ImageView pictureView = (ImageView) findViewById(R.id.picture);
  6.  
  7.             myPic = b_factory.decode(picture_path);
  8.  
  9.             myPic.width();
  10.  
  11.             myPic.height();
  12.  
  13.             // There are many more set... of this class but I just needed this one, do use as you need
  14.  
  15.             pictureView.setImageBitmap(myPic);
  16.  
  17. ...
  18.  
  19.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.    
  2.  
  3. ...
  4.  
  5. <ImageView id="@+id/picture"      
  6.  
  7.      android:layout_width="wrap_content"
  8.  
  9.       android:layout_height="wrap_content"
  10.  
  11.       android:layout_weight="1" />
  12.  
  13. ...
  14.  
  15.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Postby bavarol » Fri Aug 08, 2008 6:29 pm

Hi cgreen,
Thx a lot because your example has helped me.
I can show a Dialog as I wanted
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.          
  2.  
  3. private void showDialog(String description, String picture_path, int latitude, int longitude){
  4.  
  5.                                          
  6.  
  7.                     // touractivity is an instance of my MapActivity
  8.  
  9.                     // usually "this"
  10.  
  11.                     dia = new Dialog(tourActivity);
  12.  
  13.                    
  14.  
  15.                    
  16.  
  17.                     View contentView = tourActivity.getViewInflate().inflate(R.layout.info,null,null);
  18.  
  19.                                        
  20.  
  21.                    
  22.  
  23.                     TextView descriptionView = (TextView) contentView.findViewById(R.id.descriptionString);
  24.  
  25.                     descriptionView.setText(description);                      
  26.  
  27.  
  28.  
  29.                        
  30.  
  31.                     TextView latitudeView = (TextView) contentView.findViewById(R.id.latitudeString);
  32.  
  33.                     latitudeView.setText((Integer.valueOf(latitude)).toString());
  34.  
  35.                        
  36.  
  37.    
  38.  
  39.                     TextView longitudeView = (TextView) contentView.findViewById(R.id.longitudeString);
  40.  
  41.                     longitudeView.setText((Integer.valueOf(latitude)).toString());
  42.  
  43.                                                                                                        
  44.  
  45.                    
  46.  
  47.                     dia.setContentView(contentView);
  48.  
  49.                     dia.setTitle("Touristic Info");
  50.  
  51.                    
  52.  
  53.                        
  54.  
  55.                    
  56.  
  57.                     dia.show();
  58.  
  59.    
  60.  
  61.                
  62.  
  63.           }
  64.  
  65.     }
Parsed in 0.040 seconds, using GeSHi 1.0.8.4


Dialog Class has no isShowing() Method like PopupWindow but we can easy control whether an instance of Dialog Class runs.

I hope, this code helps someone ;)

p.s. I) In order to show a picture we must decode the bitmap of "picture_path" and then we set that Bitmap on ImageView as tipically

p.s. II) I dismiss the emerging dialog ouside that method.
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Want to display image from private area

Postby chetandl » Sat Mar 21, 2009 11:21 am

I cant get your code.
Most of the methods are deprecated.

I want to display image on ImageView from applications private area.
chetandl
Junior Developer
Junior Developer
 
Posts: 23
Joined: Tue Mar 17, 2009 9:17 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests