小编Jor*_* B.的帖子

如何以编程方式隐藏按钮?

我有一个RelativeLayout包含两个按钮.它们相互重叠.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF">


<Button android:text="Play"  
    android:id="@+id/play"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom = "true">
</Button>

<Button android:text="Stop "
    android:id="@+id/stop" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_alignParentBottom = "true">
</Button>


</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我想以编程方式一次只显示一个按钮,同时调用其click事件.

我尝试过:

playButton.setVisibility(1);
Run Code Online (Sandbox Code Playgroud)

但它不起作用.以下是我想要做的一个例子.

playButton = (Button) findViewById(R.id.play);
playButton.setVisibility(1);
playButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        //when play is clicked show stop button and hide play button

    }
});
Run Code Online (Sandbox Code Playgroud)

android

139
推荐指数
6
解决办法
23万
查看次数

仅限键盘编号的EditText视图

我想要一个只有可见数字的键盘到EditText视图.没有任何其他角色.

我已经测试了所有可用的输入并且不起作用.我已经搜索了一种只使用数字键盘的方法,但我只看到过引用:

android: inputType = "numberPassword"
Run Code Online (Sandbox Code Playgroud)

但我想在EditText中看到可见的数字.有人可以帮帮我吗?

我想要一个这样的键盘:(numberPassword)

在此输入图像描述

我尝试过:

android:digits="0123456789"
android:inputType="phone"
Run Code Online (Sandbox Code Playgroud)

android:inputType="number"
Run Code Online (Sandbox Code Playgroud)

看起来像那样:

在此输入图像描述

android android-layout android-edittext

43
推荐指数
5
解决办法
8万
查看次数

标签 统计

android ×2

android-edittext ×1

android-layout ×1