Why it's wrong!!!???

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

Why it's wrong!!!???

Postby yanyueshen » Fri May 29, 2009 4:31 pm

I am a new developer of android. I have a gridview of pictures. And I want show one of them when I click gridview. but I always give the error message : the application has stepped unexpectedly. Could anybody can tell how to deal with it.
the code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void onCreate(Bundle savedInstanceState) {
  2.  
  3.         super.onCreate(savedInstanceState);
  4.  
  5.         setContentView(R.layout.main);
  6.  
  7.        
  8.  
  9.         final GridView gridview = (GridView) findViewById(R.id.gridview);
  10.  
  11.        
  12.  
  13.         try
  14.  
  15.         {
  16.  
  17.                 gridview.setAdapter(new ImageAdapter(this));
  18.  
  19.                
  20.  
  21.                 gridview.setOnItemClickListener(new OnItemClickListener()
  22.  
  23.                 {
  24.  
  25.                         @Override
  26.  
  27.                         public void onItemClick(AdapterView parent,View v,int pos,long id){    
  28.  
  29.                                 Intent intent = new Intent(HelloGridView.this, ViewOneImage.class);
  30.  
  31.                         //Uri u = Uri.parse(gridview.getSelectedItemId() + "");
  32.  
  33.                         //i.setData(u);
  34.  
  35.                         HelloGridView.this.startActivityForResult(intent, REQUEST_TYPE_A);
  36.  
  37.                         finish();
  38.  
  39.                         }
  40.  
  41.                 });
  42.  
  43.         }
  44.  
  45.         catch(Exception ex)
  46.  
  47.         {
  48.  
  49.                  Log.i("err", ex.getMessage());
  50.  
  51.         }
  52.  
  53.     }
  54.  
  55.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


the code of the new activity which I want to show the picture.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class ViewOneImage  extends Activity{
  3.  
  4. LinearLayout mLinearLayout;
  5.  
  6.        
  7.  
  8.         private Intent _intent;
  9.  
  10.        
  11.  
  12.     @Override
  13.  
  14.     public void onCreate(Bundle savedInstanceState) {
  15.  
  16.         super.onCreate(savedInstanceState);
  17.  
  18.         setContentView(R.layout.main);
  19.  
  20.         setTitle(R.string.View_image);     // I just doubt if the code cause the error, so I replaced them to this. but it doesn't work!  
  21.  
  22.     }
  23.  
  24. }
  25.  
  26.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

thanks for your answer!
yanyueshen
Once Poster
Once Poster
 
Posts: 1
Joined: Thu May 28, 2009 6:38 am

Top

Postby Moons » Sun May 31, 2009 9:42 am

What is the Error (run your program in debug mode it will show your the error)
Moons
Developer
Developer
 
Posts: 25
Joined: Fri Feb 13, 2009 9:19 pm

Postby divestoclimb » Tue Jun 02, 2009 2:24 am

You can also do a adb logcat to see the full trace of the exception that's thrown.

Without seeing that, I'll give it a shot in the dark... did you add the second activity to the Android manifest file?
divestoclimb
Developer
Developer
 
Posts: 33
Joined: Mon May 11, 2009 7:46 pm

Top

Return to View, Layout & Resource Problems

Who is online

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