Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 意图不是开始新的活动_Java_Android Studio_Android Intent_Android Activity - Fatal编程技术网

Java 意图不是开始新的活动

Java 意图不是开始新的活动,java,android-studio,android-intent,android-activity,Java,Android Studio,Android Intent,Android Activity,这是我的密码。我已将新活动添加到manifest.xml中。try/catch块未返回任何exeption。当我按下按钮,土司被执行和显示,但页面没有改变。此onClickListener位于适配器方法“getView”内,因此可以通过适配器生成的任何按钮获取它。我试着把其他事件,他们的工作!唯一没有做的就是去参加新的活动 这是我调试并单击按钮时的日志: public void onClick(View v) { Toast.makeText(MainActivity.this,"Y

这是我的密码。我已将新活动添加到manifest.xml中。try/catch块未返回任何exeption。当我按下按钮,土司被执行和显示,但页面没有改变。此onClickListener位于适配器方法“getView”内,因此可以通过适配器生成的任何按钮获取它。我试着把其他事件,他们的工作!唯一没有做的就是去参加新的活动

这是我调试并单击按钮时的日志:

 public void onClick(View v) {
     Toast.makeText(MainActivity.this,"You taped!",Toast.LENGTH_SHORT).show();
     try {
         startActivity(new Intent(MainActivity.this, FuelChoiceActivity.class));
     }catch (Exception e){
         System.out.println(e);
     }
 }

谢谢你的阅读和时间。我很感激你的想法。

我的主要活动是扩展活动

 
D/AbsListView: reportScrollStateChange: newState = 0, mLastScrollState = 0, mOnScrollListener = null, mScrollY = 0, mTouchMode = -1, mFirstPosition = 0
V/SettingsInterface:  from settings cache , name = sound_effects_enabled , value = 0
D/ActivityThread: ACT-AM_ON_PAUSE_CALLED ActivityRecord{2c1d62f0 token=android.os.BinderProxy@32487069 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity}}
D/ActivityThread: ACT-PAUSE_ACTIVITY handled : 1 / android.os.BinderProxy@32487069
D/AbsListView: onWindowFocusChanged: hasWindowFocus=false, this=com.example.stamatis.redhotpepper.ExpandableHeightGridView{1dffd375 VFED.VC. .F...... 8,0-472,965 #7f0c0053 app:id/mygridview}
D/OpenGLRenderer: Flushing caches (mode 0)
D/GraphicBuffer: register, handle(0xb884d518) (w:177 h:66 s:192 f:0x1 u:0x000f02)
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
D/GraphicBuffer: unregister, handle(0xb884d518) (w:177 h:66 s:192 f:0x1 u:0x000f02)
D/GraphicBuffer: register, handle(0xb884d518) (w:177 h:66 s:192 f:0x1 u:0x000f02)
V/ActivityThread: Handling launch of ActivityRecord{1ff7b407 token=android.os.BinderProxy@19bbf934 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.FuelChoiceActivity}}
V/ActivityThread: ActivityRecord{1ff7b407 token=android.os.BinderProxy@19bbf934 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.FuelChoiceActivity}}: app=android.app.Application@a0dbe1c, appName=com.example.stamatis.redhotpepper, pkg=com.example.stamatis.redhotpepper, comp={com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.FuelChoiceActivity}, dir=/data/app/com.example.stamatis.redhotpepper-1/base.apk
D/ActivityThread: ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{1ff7b407 token=android.os.BinderProxy@19bbf934 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.FuelChoiceActivity}}
D/ActivityThread: ACT-PAUSE_ACTIVITY_FINISHING handled : 0 / android.os.BinderProxy@19bbf934
V/ActivityThread: Performing resume of ActivityRecord{2c1d62f0 token=android.os.BinderProxy@32487069 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity}}
D/ActivityThread: ACT-AM_ON_RESUME_CALLED ActivityRecord{2c1d62f0 token=android.os.BinderProxy@32487069 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity}}
V/ActivityThread: Resume ActivityRecord{2c1d62f0 token=android.os.BinderProxy@32487069 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity}} started activity: false, hideForNow: false, finished: false
V/ActivityThread: Resuming ActivityRecord{2c1d62f0 token=android.os.BinderProxy@32487069 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity}} with isForward=true
V/PhoneWindow: DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{dfe4562 com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{1d6eaa25 V.E..... R.....I. 0,0-480,782}
V/ActivityThread: Scheduling idle handler for ActivityRecord{2c1d62f0 token=android.os.BinderProxy@32487069 {com.example.stamatis.redhotpepper/com.example.stamatis.redhotpepper.MainActivity}}
D/ActivityThread: ACT-RESUME_ACTIVITY handled : 1 / android.os.BinderProxy@32487069
D/AbsListView: onWindowFocusChanged: hasWindowFocus=true, this=com.example.stamatis.redhotpepper.ExpandableHeightGridView{1dffd375 VFED.VC. .F...... 8,0-472,965 #7f0c0053 app:id/mygridview}
V/InputMethodManager: onWindowFocus: com.example.stamatis.redhotpepper.ExpandableHeightGridView{1dffd375 VFED.VC. .F...... 8,0-472,965 #7f0c0053 app:id/mygridview} softInputMode=272 first=false flags=#1810100
D/ActivityThread: ACT-DESTROY_ACTIVITY handled : 1 / android.os.BinderProxy@19bbf934
D/OpenGLRenderer: Flushing caches (mode 0)
D/OpenGLRenderer: Flushing caches (mode 0)
D/GraphicBuffer: unregister, handle(0xb884d518) (w:177 h:66 s:192 f:0x1 u:0x000f02)
在这个活动中,我试图转移到另一个扩展了AppCombatActivity的类

public class MainActivity extends Activity
所以语法和一切都是正确的。因此,我将FuelChoiceActivity(我希望移动的活动)扩展为:

public class FuelChoiceActivity extends AppCombatActivity

似乎如果他们不扩展同一个类,你就不能转移到另一个活动

您是否在onCreate of FuelChoiceActivity中找到任何日志记录者如果我们能够访问FuelChoiceActivity FuelChoiceActivity只有基本的onCreate和其他功能,我们可以更好地了解这个问题。如果我把它作为主引擎启动,它就会工作。唯一的区别是我的主要活动扩展了活动,而FuelChoiceActivity扩展了AppCompative活动。第二个没有日志问题是第二个活动没有扩展同一个类。我将继承更改为相同的继承,并且成功了。谢谢你的时间不是为了我,而是为了未来的读者,请详细解释你到底做了什么,以及什么是“同一类”。
public class FuelChoiceActivity extends Activity