1. 程式人生 > 其它 >每日日報2021.4.14

每日日報2021.4.14

今天完成內容:

學習andriod fragment

public interface CallBack{  
    /*定義一個獲取資訊的方法*/  
    public void getResult(String result);  
}


public void getData(CallBack callBack){  
    /*獲取文字框的資訊,當然你也可以傳其他型別的引數,看需求咯*/  
    String msg = editText.getText().toString();  
    callBack.getResult(msg);  
}



leftFragment.getData(new CallBack() {  
 @Override  
       public void getResult(String result) {              /*列印資訊*/  
            Toast.makeText(MainActivity.this, "-->>" + result, 1).show();  
            }
        });




FragmentManager fManager = getSupportFragmentManager( );
FragmentTransaction fTransaction = fManager.beginTransaction();
Fragmentthree t1 = new Fragmentthree();
Fragmenttwo t2 = new Fragmenttwo();
Bundle bundle = new Bundle();
bundle.putString("key",id);
t2.setArguments(bundle); 
fTransaction.add(R.id.fragmentRoot, t2, "~~~");  
fTransaction.addToBackStack(t1);  
fTransaction.commit();

看視訊

遇到問題:

明日目標:

學習Android studio的開發