0
私はボタンをacと呼びます。クリックすると、aとbという2つのフラグメントを隠したいのですが、これは起こりません。この作品を作るには?fragを非表示にしてこれを表示する方法をリフレッシュする方法
package cmsc436.lab5;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class Lab5Activity extends Activity implements button2interface, button1interface{
/** Called when the activity is first created. */
button1 a;
button2 b ;
FragmentManager fragmentManager;
FragmentTransaction fragmentTransaction;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
a= new button1();
b=new button2();
final LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setId(1);
fragmentManager = getFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction();
//a.getActivity().findViewById(1);
fragmentTransaction.add(linearLayout.getId(), a);
fragmentTransaction.add(linearLayout.getId(), b);
fragmentTransaction.commit();
final Button ac =new Button(this);
ac.setText("c button");
linearLayout.addView(ac);
setContentView(linearLayout);
ac.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
fragmentTransaction.hide(a);
fragmentTransaction.hide(b);
}
});
}
@Override
public void buttonClick1() {
if (b.isHidden()) {
fragmentTransaction.show(b);
}
else {
fragmentTransaction.hide(b);
}
}
@Override
public void buttonClick2() {
if (a.isHidden()) {
fragmentTransaction.show(a);
}
else {
fragmentTransaction.hide(a);
}
}
}
"package cmsc436.lab5;"?あなたはそれを必要とするたびに新しいものを作成する必要があります。 Lab5Activity?あなたはこのクラスを受けていますか? http://www.cs.umd.edu/class/fall2011/cmsc436/CMSC436/Welcome.htmlクラスのインストラクターがこのタイプの質問をここで要求していますか? :) – adamp