Problems with starting activity

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Problems with starting activity

Postby pakapont » Wed Jun 11, 2008 7:39 pm

These are my code, consist of two classes and two .xml files.
1. main activity
package myPackage.example.hello;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.*;
import android.widget.Button;
import android.widget.ImageView;

public class start_Hello extends Activity {
ImageView imView;
View.OnClickListener getImgListener = new View.OnClickListener() {

public void onClick(View arg0) {

// TODO Auto-generated method stub
ImageConverter img = new ImageConverter(imView.getDrawingCache());
img.EnhanceImage();

}




};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {




super.onCreate(icicle);
setContentView(R.layout.main);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.icon);

Button bt3 = (Button) findViewById(R.id.get_imagebt);
bt3.setOnClickListener(getImgListener);
imView = (ImageView) findViewById(R.id.imview);

imView.setImageBitmap(bm);
}




}

2. My Own class for display images.

package myPackage.example.hello;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.graphics.Color;
public class ImageConverter {
Bitmap bb;
int width=0,hight = 0;
public ImageConverter (Bitmap b){
bb = Bitmap.createBitmap(b);
width = bb.getHeight();
hight = bb.getHeight();
}

public Bitmap EnhanceImage(){
//may be we use colortoHSV of android na
int [] pix = new int[width*hight];
float [] componen = new float[3];
float [] componen2 = new float[3];
bb.getPixels(pix, 0, width, 0 , 0, width, hight);
for (int i = 0 ; i < pix.length ;i++){
Color.colorToHSV(pix[i], componen);
componen2[0] = componen[0];
componen2[1] = componen[1];
componen2[2] = componen[2];
//use the same V na
pix[i] = Color.HSVToColor(componen2);
}
bb.setPixels(pix, 0, width, 0, 0, width, hight);
return bb;
}

}

3. layout file
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, SoftwareEnhance"
/>
<Button id="@+id/get_imagebt"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get an image"
android:layout_gravity="center"
/>

<ImageView id="@+id/imview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>

</LinearLayout>

4. Project property file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myPackage.example.hello">
<application android:icon="@drawable/icon">
<activity android:name=".start_Hello" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

When I tried to run the application in debug mode, there aresome errors like below;
Class File Editor...... Source not found (ActivityThread.class), this similar to some other too such as InvocationTargetException.class.

Could somebody help?
pakapont
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jun 03, 2008 5:54 pm

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 5 guests