1
我正在做一个Android应用程序,并有一个奇怪的问题。我需要一个ViewFlipper 5个选项卡。我做了一个5页按钮的页面布局。我用OnClickListener
和翻转标签工作正常,但我需要setPressed(true)
为一个按钮,我不能这样做。有重绘问题或某事。我在网上寻找解决方案,但没有其他人有这个问题?我做错了什么?设置按钮从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
查看编辑答案 –
雅ToggleButton的作品... TNX ...也必须使用启用和setChecked其他4个按钮导致需要一些单选按钮仍然按钮:P 毕竟,我看到我可能会使用单选按钮,购买添加他们我的皮肤:P – CoYoTe