Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从ViewFlipper(Android)按下设置按钮_Android_Button_Viewflipper - Fatal编程技术网

从ViewFlipper(Android)按下设置按钮

从ViewFlipper(Android)按下设置按钮,android,button,viewflipper,Android,Button,Viewflipper,我正在制作一个Android应用程序,遇到了一个奇怪的问题。我需要一个用于5个选项卡的ViewFlipper。我为一个有5个按钮的页面做了一个布局。我使用了OnClickListener,翻转选项卡可以正常工作,但我需要setPressed(true)来设置按钮,我不能这样做。有一个重新油漆的问题或什么的。我在网上寻找解决方案,但没有其他人有这个问题?我做错了什么 public void onCreate(Bundle savedInstanceState) { super.onCrea

我正在制作一个Android应用程序,遇到了一个奇怪的问题。我需要一个用于5个选项卡的ViewFlipper。我为一个有5个按钮的页面做了一个布局。我使用了
OnClickListener
,翻转选项卡可以正常工作,但我需要
setPressed(true)
来设置按钮,我不能这样做。有一个重新油漆的问题或什么的。我在网上寻找解决方案,但没有其他人有这个问题?我做错了什么

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);
}
在每个clickListener中使用setEnabled()代替setPressed

            flipper_info.setDisplayedChild(0);
            buttons[currentTab].setEnabled(true);
            currentTab = 0;
            buttons[0].setEnabled(false);

对于背景颜色更改,请使用toggleButton,它将允许您为打开/关闭状态设置选择器。。。在clickListener中切换状态

在每个clickListener中使用setEnabled()而不是setPressed

            flipper_info.setDisplayedChild(0);
            buttons[currentTab].setEnabled(true);
            currentTab = 0;
            buttons[0].setEnabled(false);


对于背景颜色更改,请使用toggleButton,它将允许您为打开/关闭状态设置选择器。。。在clickListener中切换状态

Tnx到这个,但我不能用这个。我需要更改按钮的bgd,并使用选择器。无法进入选择器(项目)此已启用属性?Ya ToggleButton有效…tnx…还必须为其他4个按钮使用enable和setChecked,因为仍然需要一些单选按钮:P毕竟我看到我可能可以使用单选按钮,购买以添加它们我的皮肤:Psorry,我对这个美丽的网站是新的:PTnx到这个,但我不能使用这个。我需要更改按钮的bgd,并使用选择器。无法进入选择器(项目)此启用属性?切换按钮有效…tnx…还必须为其他4个按钮使用enable和setChecked,因为仍然需要一些单选按钮:P毕竟我看到我可能可以使用单选按钮,购买添加它们我的皮肤:Psorry,我在这个美丽的网站上是新的:P