亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

實現點擊一個界面上的按鈕彈出另一個界面,另一個界面以對話框形式顯示

實現點擊一個界面上的按鈕彈出另一個界面,另一個界面以對話框形式顯示

慕桂英2234914 2017-07-31 16:41:26
<activity android:name=".FirstActivity"> ? ?<intent-filter> ? ? ? ?<action android:name="android.intent.action.MAIN" /> ? ? ? ?<category android:name="android.intent.category.LAUNCHER" /> ? ?</intent-filter></activity><activity ? ?android:name=".SecondActivity" ? ?android:theme="@android:style/Theme.DeviceDefault.Dialog" ? ?/>btn1.setOnClickListener(new View.OnClickListener(){ ? ?@Override ? ?public void onClick(View view) { ? ? ? ?Intent intent = new Intent(FirstActivity.this,SecondActivity.class); ? ? ? ?FirstActivity.this.startActivity(intent); ? ?}});報錯:07-31 16:38:59.871 7159-7159/com.example.form.myformcomponent I/locat: 執行了--------------onCreate()方法07-31 16:38:59.991 7159-7159/com.example.form.myformcomponent I/locat: 執行了--------------onStart()方法07-31 16:39:00.001 7159-7159/com.example.form.myformcomponent I/locat: 執行了--------------onResume()方法07-31 16:39:00.131 7159-7218/com.example.form.myformcomponent I/OpenGLRenderer: Initialized EGL, version 1.407-31 16:39:00.151 7159-7159/com.example.form.myformcomponent W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView07-31 16:39:03.921 7159-7159/com.example.form.myformcomponent I/locat: 執行了--------------onPause()方法07-31 16:39:03.931 7159-7159/com.example.form.myformcomponent E/AndroidRuntime: FATAL EXCEPTION: mainProcess: com.example.form.myformcomponent, PID: 7159java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.form.myformcomponent/com.example.form.myformcomponent.SecondActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2586)at android.app.ActivityThread.access$900(ActivityThread.java:163)at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)at android.os.Handler.dispatchMessage(Handler.java:102)at android.os.Looper.loop(Looper.java:135)at android.app.ActivityThread.main(ActivityThread.java:5574)at java.lang.reflect.Method.invoke(Native Method)at java.lang.reflect.Method.invoke(Method.java:372)at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:962)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:356)at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:325)at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:286)at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)at com.example.form.myformcomponent.SecondActivity.onCreate(SecondActivity.java:12)at android.app.Activity.performCreate(Activity.java:6084)at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2472)at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2586) at android.app.ActivityThread.access$900(ActivityThread.java:163) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5574) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:962) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 07-31 16:39:03.961 7159-7159/com.example.form.myformcomponent I/Process: Sending signal. PID: 7159 SIG: 9
查看完整描述

1 回答

?
蜂之谷

TA貢獻564條經驗 獲得超863個贊

<activity
???android:name=".SecondActivity"
???android:theme="@style/Theme.AppCompat.Dialog"
???/>

錯誤不是提示了嗎,改下主題就好了

查看完整回答
反對 回復 2017-07-31
  • 慕桂英2234914
    慕桂英2234914
    嗯,看到了,為什么在eclipse里的主題在android studio就不能用了?
  • 蜂之谷
    蜂之谷
    都可以用啊,關鍵看你activity繼承的什么,貌似eclipse繼承的Activity,android studio繼承的AppCompatActivity
  • 1 回答
  • 0 關注
  • 4250 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號