setImageResource fails and closes the application unexpectedly !

by Sasikumar Gandhi » Thu, 01 Apr 2010 07:26:06 GMT


Sponsored Links
 Hi-

I am trying to display the image on the ImageView object. But the
setImageResource
fails to display the image.

Here is my XML file looks like:


<?xml version=*"1.0"* encoding=*"utf-8"*?>

<LinearLayout xmlns:android=*" http://schemas.android.com/apk/res/android" ;
*

android:orientation=*"vertical"
*

android:layout_width=*"fill_parent"
*

android:layout_height=*"fill_parent"*>

<FrameLayout

android:orientation=*"vertical"
*

android:layout_width=*"fill_parent"
*

android:layout_height=*"fill_parent"
*

android:layout_weight=*"1"*>

<ImageView

id=*"@+id/batteryLevelview"*

android:layout_width=*"wrap_content"*

android:layout_height=*"wrap_content"*

android:layout_gravity=*"center"*/>

</FrameLayout>

</LinearLayout>

Here is my code:

@Override

*public* *void* onCreate(Bundle savedInstanceState) {

*super*.onCreate(savedInstanceState);

setContentView(R.layout.*main*);

ImageView batteryLevelImage = (ImageView) findViewById(R.id.*
batteryLevelview*);

batteryLevelImage.setImageResource(R.drawable.*notconnected*);

}

I could not find what's wrong. I tried using the LinearLayout and that did
not help. Please help me what's wrong.

thanks,

--



setImageResource fails and closes the application unexpectedly !

by Sasi » Thu, 01 Apr 2010 07:35:23 GMT


 Hi-

I am trying to display the image on the ImageView object. But the
setImageResource fails to display the image. If it succeeds, I would
like to update image on ImageView object based on some criteria.

Here is my XML layout file looks like:

<?
xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ImageView
id="@+id/batteryLevelview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
</LinearLayout>

Here is my code:

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView batteryLevelImage = (ImageView)
findViewById(R.id.batteryLevelview);
batteryLevelImage.setImageResource(R.drawable.notconnected);
}

I could not find what's wrong. I tried using the LinearLayout and that
did not help. Please help me what's wrong.

thanks,

--


Sponsored Links


setImageResource fails and closes the application unexpectedly !

by madmax » Thu, 01 Apr 2010 15:11:02 GMT


 Can u put the error log here please so that i can know what the actual
error u get is...


   Peace,
    Prafull.




--



setImageResource fails and closes the application unexpectedly !

by nayana urs » Thu, 01 Apr 2010 19:06:54 GMT


 hiiii all
am doing photo editting application am able to edit images but not getting
how to save it can anyone please let me know how to do it
with regards
   Nayana






>



setImageResource fails and closes the application unexpectedly !

by Sasi » Fri, 02 Apr 2010 05:29:04 GMT


 Can you please let me know where can I find the error log? I am new to
android development.

thanks,
Sasi





--



setImageResource fails and closes the application unexpectedly !

by Mark Murphy » Fri, 02 Apr 2010 05:31:37 GMT


 


Use adb logcat, DDMS, or the DDMS perspective in Eclipse to view the
Java stack trace associated with unhandled exceptions.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Training...At Your Office:  http://commonsware.com/training 

--



setImageResource fails and closes the application unexpectedly !

by nayana urs » Fri, 02 Apr 2010 23:08:33 GMT


 hiiii all
am doing photo editting application am able to edit images but not getting
how to save it can anyone please let me know how to do it
with regards
   Nayana







>



Other Threads

1. Problem with looping through the buttons in the Layout

I'm using TableLayout for my application.
I do have 16 buttons (4 rows and 4 columns) inside the layout.

I'm able to assign the text to each button by assigning value to
R.id.Button01, 02, 03 .... Button16.

Take this as an example code.


                ((Button)findViewById(R.id.Button01)).setText(list.get
(0).toString());
                
((Button)findViewById(R.id.Button02)).setText(list.get(1).toString
());
                
((Button)findViewById(R.id.Button03)).setText(list.get(2).toString
());
                
((Button)findViewById(R.id.Button04)).setText(list.get(3).toString
());
                
((Button)findViewById(R.id.Button05)).setText(list.get(4).toString
());
                
((Button)findViewById(R.id.Button06)).setText(list.get(5).toString
());
                
((Button)findViewById(R.id.Button07)).setText(list.get(6).toString
());
                
((Button)findViewById(R.id.Button08)).setText(list.get(7).toString
());
                
((Button)findViewById(R.id.Button09)).setText(list.get(8).toString
());
                
((Button)findViewById(R.id.Button10)).setText(list.get(9).toString
());
                
((Button)findViewById(R.id.Button11)).setText(list.get(10).toString
());
                
((Button)findViewById(R.id.Button12)).setText(list.get(11).toString
());
                
((Button)findViewById(R.id.Button13)).setText(list.get(12).toString
());
                
((Button)findViewById(R.id.Button14)).setText(list.get(13).toString
());
                
((Button)findViewById(R.id.Button15)).setText(list.get(14).toString
());
                
((Button)findViewById(R.id.Button16)).setText(list.get(15).toString
());


But what I want is similar to following code.

      for(int i=0; i< 16; i++)
      {

           ((Button)findViewById(R.id.Button[i] )).setText(list.get
(i).toString());
      }

Thanks,
-Anil

--~--~---------~--~----~------------~-------~--~----~

2. AlertDialog lose on change rotation

I've an application with a MapActivity used how main activity. I
inserted an AlertDialog to show and edit a few infos. When I change
from portrait to landscape for open the keyboard, my AlertDialog is
detroied without replaced, then I must recall the command menu for
show again my AlertDialog.

Any suggest to mantain open the AlertDialog from portrait to landscape
and viceversa ?

thanks
--~--~---------~--~----~------------~-------~--~----~

3. Problem with simpleCursorAdapter, ListView backed by a managed cursor

4. Create new category

5. size of Bitmap

6. Not able to add account on email client of emulator(sdk r2)

7. How to re-install & sign android built-in applications