how to call another activity using listview item r

2019-08-25 05:24发布

问题:

I am making an application in which fetching data from xml using url in listview, now i want to call another activity using listview item row, for example :- if user will click first listview row, then need to call item.class, actually i am able to call another activity if i will not use web url in next activity,but if i want to call activity that also fetching data from url using xml parser, then i am getting this error :- Unfortunately app has stopped, why, please someone tell me how can i solve this?

First.java:

list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) 
{
    if(position==0)
    {
            Intent in = new Intent(First.this, Item.class);
        startActivity(in);
    }
}

Item.java:

    public class Item extends Activity {
// All static variables
static final String URL = "http://***.net/android/item.xml";
// XML node keys
static final String KEY_NODE = "pick"; // parent node
static final String KEY_TITLE = "title";
static final String KEY_DESC = "description";
    }

Manifest.xml:

      <activity
        android:name=".First"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="Item"></activity>

回答1:

I think here is the error : <activity android:name="Item"></activity>

it must be

 <activity android:name=".Item"></activity>