Image is not Displayed

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

Image is not Displayed

Postby saty_32016 » Mon Mar 17, 2008 2:17 pm

Hi,
i want to show image thru jave code,but image is not displaying(JPG).

here is my code.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package Com.MIGE.Image;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.graphics.Bitmap;
  8.  
  9. import android.graphics.BitmapFactory;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.widget.ImageView;
  14.  
  15. import android.widget.LinearLayout;
  16.  
  17. import android.widget.LinearLayout.LayoutParams;
  18.  
  19.  
  20.  
  21. public class Image extends Activity {
  22.  
  23.     /** Called when the activity is first created. */
  24.  
  25.     @Override
  26.  
  27.     public void onCreate(Bundle icicle) {
  28.  
  29.         super.onCreate(icicle);
  30.  
  31.         LinearLayout linLayout = new LinearLayout(this);
  32.  
  33.         Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.gallery_background_1);
  34.  
  35.         int width = mBitmap.getWidth();
  36.  
  37.         int height = mBitmap.getHeight();
  38.  
  39.         Bitmap sBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height);        
  40.  
  41.         ImageView iView = new ImageView(this);
  42.  
  43.         iView.setImageBitmap(sBitmap);
  44.  
  45.         linLayout.addView(iView,new LinearLayout.LayoutParams(
  46.  
  47.                 LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT
  48.  
  49.         ) );
  50.  
  51.         setContentView(R.layout.main);
  52.  
  53.     }
  54.  
  55. }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


what wrong i did?
Attachments
gallery_background_1.jpg
Attached Gallery JPEG image
gallery_background_1.jpg (27.85 KiB) Viewed 617 times
saty_32016
Developer
Developer
 
Posts: 27
Joined: Mon Mar 10, 2008 4:47 am

Top

Postby venkat » Mon Mar 17, 2008 2:48 pm

Please try below line


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.main)----->setContentView(linLayout)
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


:) ;)
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Postby saty_32016 » Tue Mar 18, 2008 5:43 am

venkat wrote:Please try below line


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.main)----->setContentView(linLayout)
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


:) ;)

Thanks it works.

now able to display and edit image.
saty_32016
Developer
Developer
 
Posts: 27
Joined: Mon Mar 10, 2008 4:47 am

Postby venkat » Tue Mar 18, 2008 8:32 am

saty_32016 wrote:
venkat wrote:Please try below line


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.main)----->setContentView(linLayout)
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


:) ;)

Thanks it works.

now able to display and edit image.


You are welcome . :)
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests