2

i have a listview and when i click on an item it display a message and then when i click "ok" i want to pass to another activity, this my code:

 public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
// TODO Auto-generated method stub
 ServerContent item = listAdapter.getItem(position);
Log.e("onitemclick","listadapter");
item.select();

newactivity n = new newactivity();
   Intent newActivity = new Intent();     
startActivity(newActivity);
            }

and i add this in the manifest.xml

<activity android:label="@string/app_name" android:name="newactivity"/>

this the newactivity :

public class newactivity {
    Intent intent;
    protected void onCreate(Bundle savedInstanceState) {

         intent = getIntent();
         intent.addCategory("category");
        //String value = intent.getStringExtra("key"); //if it's a string you stored.
}

    private Intent getIntent() {
        // TODO Auto-generated method stub
        Intent n = new Intent();
        n.addCategory("  ");
        return n;
    }

i got those errors

10-18 11:01:02.277: W/dalvikvm(333): threadid=1: thread exiting with uncaught exception (group=0x40015560)
10-18 11:01:02.297: E/AndroidRuntime(333): FATAL EXCEPTION: main
10-18 11:01:02.297: E/AndroidRuntime(333): android.content.ActivityNotFoundException: No Activity found to handle Intent {  }
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.app.Activity.startActivityFromChild(Activity.java:3067)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.app.Activity.startActivityForResult(Activity.java:2847)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.app.Activity.startActivity(Activity.java:2933)
10-18 11:01:02.297: E/AndroidRuntime(333):  at com.upnpexample.BrowseServerActivity$1$1.onItemClick(BrowseServerActivity.java:227)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.widget.ListView.performItemClick(ListView.java:3513)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.os.Handler.handleCallback(Handler.java:587)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.os.Handler.dispatchMessage(Handler.java:92)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.os.Looper.loop(Looper.java:123)
10-18 11:01:02.297: E/AndroidRuntime(333):  at android.app.ActivityThread.main(ActivityThread.java:3683)
10-18 11:01:02.297: E/AndroidRuntime(333):  at java.lang.reflect.Method.invokeNative(Native Method)
10-18 11:01:02.297: E/AndroidRuntime(333):  at java.lang.reflect.Method.invoke(Method.java:507)
10-18 11:01:02.297: E/AndroidRuntime(333):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-18 11:01:02.297: E/AndroidRuntime(333):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-18 11:01:02.297: E/AndroidRuntime(333):  at dalvik.system.NativeStart.main(Native Method)
10-18 11:01:05.376: I/Process(333): Sending signal. PID: 333 SIG: 9
4

2 回答 2

1

Activityname mustbe like this .newactivity

justchange like this

  <activity android:label="@string/app_name" android:name=".newactivity"/>
于 2012-10-18T14:41:53.230 回答
0

I hope its not a typo:

    <activity android:label="@string/app_name" android:name="newactivity"/>

There is no "." here before the activity name. It should be like:

    <activity android:label="@string/app_name" android:name=".newactivity"/>

or you can even specify full qualified name of the activity eg.

    <activity android:label="@string/app_name" android:name="com.yourproject.activity.newactivity"/>
于 2012-10-18T14:42:51.180 回答