1
私はAndroidアプリを作っていて、奇妙な問題があります。私は5つのタブのViewFlipperが必要です。私は5つのボタンでページのレイアウトを作った。 OnClickListener
を使用し、タブを反転すると問題なく動作しますが、ボタンはsetPressed(true)
にする必要があります。再描画の問題などがあります。私はネット上で解決策を探しましたが、誰もこの問題を抱えていませんか?私は何を間違えたのですか? setEnabled設定ボタンをViewFlipper(Android)から押した
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
factory = getLayoutInflater();
skin = factory.inflate(R.layout.skin_tab_raspored, null);
vremelayout = (LinearLayout) skin.findViewById(R.id.vreme);
infolayout = (LinearLayout) skin.findViewById(R.id.info);
buttons[0] = (Button) skin.findViewById(R.id.pon);
buttons[1] = (Button) skin.findViewById(R.id.uto);
buttons[2] = (Button) skin.findViewById(R.id.sre);
buttons[3] = (Button) skin.findViewById(R.id.cet);
buttons[4] = (Button) skin.findViewById(R.id.pet);
buttons[0].setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper_info.setDisplayedChild(0);
buttons[currentTab].setPressed(false);
currentTab = 0;
buttons[0].setPressed(true);
}
});
buttons[1].setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper_info.setDisplayedChild(1);
buttons[currentTab].setPressed(false);
currentTab = 1;
buttons[1].setPressed(true);
}
});
buttons[2].setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper_info.setDisplayedChild(2);
buttons[currentTab].setPressed(false);
currentTab = 2;
buttons[2].setPressed(true);
}
});
buttons[3].setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper_info.setDisplayedChild(3);
buttons[currentTab].setPressed(false);
currentTab = 3;
buttons[3].setPressed(true);
}
});
buttons[4].setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
flipper_info.setDisplayedChild(4);
buttons[currentTab].setPressed(false);
currentTab = 4;
buttons[4].setPressed(true);
}
});
buttons[0].setPressed(true);
add_time(); //adding content to vremelayout
flipper_info = new ViewFlipper(this);
flipper_info.addView(this.addContentToInfo(Dan.pon));//adding content to infolayout
flipper_info.addView(this.addContentToInfo(Dan.uto));
flipper_info.addView(this.addContentToInfo(Dan.sre));
flipper_info.addView(this.addContentToInfo(Dan.cet));
flipper_info.addView(this.addContentToInfo(Dan.pet));
infolayout.addView(flipper_info);
setContentView(skin);
}
これにはTnxが使用できません。私はボタンのbgdを変更し、その使用セレクタのために必要です。この有効な属性をセレクタ(項目)で取得できませんか? – CoYoTe
check編集の回答 –
Ya ToggleButton works ... tnx ...他の4つのボタンに対してもenableとsetCheckedを使用する必要があります。ボタンのラジオボタンが必要です:P ラジオボタンを使用している可能性があります私の肌を追加してください:P – CoYoTe