Android如何以编程方式隐藏电话号码

时间:2016-03-16 19:12:39

标签: android hide phone-number phone-call

如果不进入设置,如何在通话过程中隐藏或显示我的电话号码?

1 个答案:

答案 0 :(得分:0)

您可以使用复选框实现此目的:

 <CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/cb_Show" />
 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/text"
   />

_

    CheckBox cbShow = (CheckBox) findViewById(R.id.cb_Show);
TextView text=findViewById(R.id.text);

text.setText("some text to hide");

        cbShow.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked)
                    text.setVisibility(VIEW.INVISIBLE);
                else
                    text.setVisibility(VIEW.VISIBLE);
            }
        });

或者您可以使用toggleButton代替example

祝你好运