alert notification error...

Put your problem here if it does not fit any of the other categories.

alert notification error...

Postby Archana » Thu Feb 28, 2008 1:21 pm

This is the code wich i am using.at first time it wil display.all the inform ation i,which i have give in setText();
in the same way i try to call another showToast method.but its not displaying its content...




Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class MatchingProfile extends Activity {
  2.  
  3.  
  4.  
  5.         int count1=0;
  6.  
  7.         //NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
  8.  
  9.     @Override
  10.  
  11.     protected void onCreate(Bundle icicle) {
  12.  
  13.         super.onCreate(icicle);
  14.  
  15.  
  16.  
  17.         setContentView(R.layout.incomingmessage);
  18.  
  19.  
  20.  
  21.         Button button = (Button) findViewById(R.id.notify);
  22.  
  23.         button.setOnClickListener(new Button.OnClickListener() {
  24.  
  25.                 public void onClick(View v)
  26.  
  27.                 {
  28.  
  29.                     showToast();
  30.  
  31.                     showToast1();       //2nd time calling
  32.  
  33.                 }
  34.  
  35.             });
  36.  
  37.     }
  38.  
  39.  
  40.  
  41.    
  42.  
  43.     protected void showToast()
  44.  
  45.  
  46.  
  47.     {
  48.  
  49.         // create the view
  50.  
  51.         View view = inflateView(R.layout.incoming_message_panel);
  52.  
  53.  
  54.  
  55.  
  56.  
  57.         // set the text in the view
  58.  
  59.         TextView tv = (TextView)view.findViewById(R.id.message);
  60.  
  61.         tv.setText("\n25,Male,5,55,Madipakkam\n"+
  62.  
  63.                      "\n24,Male,6,65,Madipakkam\n"+
  64.  
  65.                     "\n26,Male,5.5,58,Madipakkam\n"+
  66.  
  67.                      "\n27,Male,4.5,75,Madipakkam\n"+
  68.  
  69.                      "\n28,Male,5,66,Madipakkam\n"+
  70.  
  71.                      "\n29,Male,4,78,Madipakkam\n");
  72.  
  73.  
  74.  
  75.         // show the toast
  76.  
  77.         Toast toast = new Toast(this);
  78.  
  79.         toast.setView(view);
  80.  
  81.         toast.setDuration(Toast.LENGTH_LONG);
  82.  
  83.         toast.show();
  84.  
  85.  
  86.  
  87.  
  88.  
  89.     }
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.     private View inflateView(int resource) {
  98.  
  99.         ViewInflate vi = (ViewInflate)getSystemService(Context.INFLATE_SERVICE);
  100.  
  101.         return vi.inflate(resource, null, null);
  102.  
  103.     }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. protected void showToast1()
  110.  
  111.  
  112.  
  113.     {
  114.  
  115.         // create the view
  116.  
  117.         View view = inflateView(R.layout.incoming_message_panel);
  118.  
  119.  
  120.  
  121.  
  122.  
  123.         // set the text in the view
  124.  
  125.         TextView tv = (TextView)view.findViewById(R.id.message);
  126.  
  127.         tv.setText("\n25,Male,5,55,Madipakkam\n"+
  128.  
  129.                      "\n24,Male,6,65,Madipakkam\n"+
  130.  
  131.                     "\n26,Male,5.5,58,Madipakkam\n"+
  132.  
  133.                      "\n27,Male,4.5,75,Madipakkam\n"+
  134.  
  135.                      "\n28,Male,5,66,Madipakkam\n"+
  136.  
  137.                      "\n29,Male,4,78,Madipakkam\n");
  138.  
  139.  
  140.  
  141.         // show the toast
  142.  
  143.         Toast toast = new Toast(this);
  144.  
  145.         toast.setView(view);
  146.  
  147.         toast.setDuration(Toast.LENGTH_LONG);
  148.  
  149.         toast.show();
  150.  
  151.  
  152.  
  153.  
  154.  
  155.     }
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.     private View inflateView(int resource) {
  164.  
  165.         ViewInflate vi = (ViewInflate)getSystemService(Context.INFLATE_SERVICE);
  166.  
  167.         return vi.inflate(resource, null, null);
  168.  
  169.     }
  170.  
  171.  
  172.  
  173.  
  174.  
  175. }
Parsed in 0.040 seconds, using GeSHi 1.0.8.4
Archana
Archana
Experienced Developer
Experienced Developer
 
Posts: 53
Joined: Thu Feb 28, 2008 12:00 pm
Location: Bangalore

Top

Postby plusminus » Thu Feb 28, 2008 2:29 pm

Hello Arachna,

you are displaying the exactly the same thing in (almost) exactly the same moment.

a.) You just do not see that 2 toast are displayed
b.) You cannot display two toasts at the same time (think they appear after each other)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 17 guests