hi sir I got this error when my app was launched. When I run my project unfortunately project was stop. This error is coming my log cat. When click on app unfortunately app was stop msg came.
我在activity_xml上放置了一個文本視圖。當點擊導航到另一個頁面,但這裏不顯示我的第一頁。 mainactivity.java和activity main.xml中存在問題。錯誤是java.lang.runtime異常:無法啓動活動組件Info {com.example.b/com.example.b.MainActivity}:java。 Lang.NullPointerExceptionjava lang運行時異常:無法啓動活動組件信息
**mainactivity.java**
andheri = (TextView) findViewById(R.id.Andheri1);
andheri.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Context context = null;
// TODO Auto-generated method stub
Intent intent = new Intent(context,andheri.class);
startActivity(intent);
}
});
**activity_xml**
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/untitled1"
>
<TextView
android:id="@+id/Andher1"
android:layout_width="80dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#FFE4B5"
android:capitalize="characters"
android:gravity="center"
android:text="Andheri"
android:textColor="#000000"
android:textColorHint="#0000CD"
android:textSize="15dp"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
**mainifest file.**
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.b.MainActivity"
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="com.example.b.andheri"
android:label="@string/app_name" >
</activity>
</application>
我相信你的背景是空的好 – Naveen 2014-11-04 09:34:40