2013-06-29 55 views
0
import android.content.Intent; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 

import android.widget.ImageView; 

import com.actionbarsherlock.app.SherlockFragment; 

public class Fragment_1 extends SherlockFragment{ 

    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
     View view = inflater.inflate(R.layout.fragment_1, 
       container, false); 
     ImageView button = (ImageView) view.findViewById(R.id.imageView1); 
     button.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View arg0) { 
       // TODO Auto-generated method stub 
       Intent intent = new Intent(getActivity(), Temp.class); 
       getActivity().startActivity(intent); 
      } 
     }); 

     return view; 
    } 



} 

我試圖從片段活動轉移到正常的活動,但其表現活動頁面即世界您好寫的,但它突然變得很遺憾停止。你能幫我麼。我試圖讓它在過去3天內工作,但無法弄清楚究竟是什麼問題。即使我檢查了千次Android清單文件.i.e。如何使用android中的actionbarsherlock中的簡單按鈕?

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.project.paul" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="17" /> 

    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" > 
     <activity 
      android:name="com.project.paul.Splash" 
      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.project.paul.Login" 
      android:theme="@android:style/Theme.Light.NoTitleBar" > 
     </activity> 
     <activity 
      android:name="com.project.paul.Option" 
      android:label="@string/title_activity_option" 
      android:theme="@style/Theme.Actionstyle" > 
     </activity> 
     <activity 
      android:name="com.project.paul.Fragment_1" 
      android:label="@string/title_activity_option" 
      android:theme="@style/Theme.Actionstyle" > 
     </activity> 
     <activity 
      android:name="com.project.paul.Fragment_2" 
      android:label="@string/title_activity_option" 
      android:theme="@style/Theme.Actionstyle" > 
     </activity> 
     <activity android:name="com.project.paul.ImageOptions" 
      > 
     </activity> 
     <activity 
      android:name="com.project.paul.Temp" 
      android:label="@string/title_activity_temp" 
      > 
     </activity> 
    </application> 

</manifest> 

如果你幫我解決問題,我會很感激。

logcat的錯誤:

06-29 22:26:43.647:E/AndroidRuntime(773):致命異常:主 06-29 22:26:43.647:E/AndroidRuntime(773):JAVA。 lang.NullPointerException 06-29 22:26:43.647:E/AndroidRuntime(773):at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576) 06-29 22:26:43.647:E/AndroidRuntime(773):在android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617) 06-29 22:26:43.647:E/AndroidRuntime(773):在android.support.v4.app .FragmentActivity.onSaveInstanceState(FragmentActivity.java:481) 06-29 22:26:43.647:E/AndroidRuntime(773 ):at android.app.Activity.performSaveInstanceState(Activity.java:1147) 06-29 22:26:43.647:E/AndroidRuntime(773):at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1216) 06-29 22:26:43.647:E/AndroidRuntime(773):在android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3129) 06-29 22:26:43.647:E/AndroidRuntime(773):在機器人.app.ActivityThread.handleStopActivity(ActivityThread.java:3188) 06-29 22:26:43.647:E/AndroidRuntime(773):在android.app.ActivityThread.access $ 900(ActivityThread.java:141) 06-29 22:26:43.647:E/AndroidRuntime(773):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1261) 06-29 22:26:43.647:E/AndroidRuntime(773):在機器人。 os.Handler.dispatchMessage(Handler.java:99) 06-29 2 2:26:43.647:E/AndroidRuntime(773):at android.os.Looper.loop(Looper.java:137) 06-29 22:26:43.647:E/AndroidRuntime(773):at android.app。 ActivityThread.main(ActivityThread.java:5041) 06-29 22:26:43.647:E/AndroidRuntime(773):在java.lang.reflect.Method.invokeNative(本機方法) 06-29 22:26:43.647 :E/AndroidRuntime(773):at java.lang.reflect.Method.invoke(Method.java:511) 06-29 22:26:43.647:E/AndroidRuntime(773):at com.android.internal.os .ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793) 06-29 22:26:43.647:E/AndroidRuntime(773):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 06-29 22:26:43.647 E/AndroidRuntime(773):at dalvik.system.NativeStart.main(Native Method) 06-29 22:26:48.096:E/Trace(793):打開跟蹤文件時出錯:沒有這樣的文件o [R目錄(2)

+0

PLZ提供日誌貓錯誤 – Androider

+0

@SyedZahidAli我張貼下面 –

+0

我的錯誤@ SyedZahidAli如果你有任何建議或例子..它將是一個幫助... –

回答

相關問題