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

為了賬號安全,請及時綁定郵箱和手機立即綁定

沒有報錯,但為什么會停止??

package com.example.myapplication;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Main3Activity extends Activity {
? ?private Button button;
? ?private Fragment fragment;
? ?private boolean flag =true;
? ?@Override
? ?protected void onCreate(Bundle savedInstanceState) {
? ? ? ?super.onCreate(savedInstanceState);
? ? ? ?setContentView(R.layout.activity_main3);
? ? ? ?button = (Button) findViewById(R.id.transform);
? ? ? ?init();
? ? ? ?button.setOnClickListener(new View.OnClickListener() {
? ? ? ? ? ?@Override
? ? ? ? ? ?public void onClick(View view) {
? ? ? ? ? ? ? ?android.app.FragmentManager fragM =getFragmentManager();
? ? ? ? ? ? ? ?FragmentTransaction bgfragmentT =fragM.beginTransaction();
? ? ? ? ? ? ? ?if(flag){
? ? ? ? ? ? ? ? ? ?fragment4 frag4=new fragment4();
? ? ? ? ? ? ? ? ? ?bgfragmentT.replace(R.id.layout,frag4);
? ? ? ? ? ? ? ? ? ?flag=false;
? ? ? ? ? ? ? ?}else {
? ? ? ? ? ? ? ? ? ?fragment3 frag3=new fragment3();
? ? ? ? ? ? ? ? ? ?bgfragmentT.replace(R.id.layout,frag3);
? ? ? ? ? ? ? ? ? ?flag=true;
? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?bgfragmentT.commit();
? ? ? ? ? ?}
? ? ? ?});


? ?}

? ?private void init() {
? ? ? ?fragment3 frag3= new fragment3();
? ? ? ?android.app.FragmentManager fragmentmanager =getFragmentManager();
? ? ? ?FragmentTransaction fragmentTransaction =fragmentmanager.beginTransaction();
? ? ? ?fragmentTransaction.add(R.id.layout,frag3);
? ? ? ?fragmentTransaction.commit();
? ?}
}

最后運行的時候會崩潰。。

正在回答

2 回答

你那些fragment是怎么寫的

0 回復 有任何疑惑可以回復我~
#1

Ma峰 提問者

謝謝您了,我也不知道怎么弄得就解決了
2016-08-21 回復 有任何疑惑可以回復我~

我和你一樣的問題,你那個現在弄好了嗎???


0 回復 有任何疑惑可以回復我~
#1

Ma峰 提問者

GG,我也不知道怎么弄得。
2016-09-21 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android攻城獅的第二門課(第1季)
  • 參與學習       111145    人
  • 解答問題       1560    個

本課程由淺入深地帶您學會Android的常用控件的開發和使用

進入課程

沒有報錯,但為什么會停止??

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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