invisiableact.xml
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/edittext" />
InvisiableAct
public class InvisiableAct extends Activity {
private EditText mEditText;
private Button mButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.invisiableact);
mEditText = (EditText) findViewById(R.id.edittext);
mButton = (Button) findViewById(R.id.button);
mButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
if (mEditText.isShown()) {
mEditText.setVisibility(View.GONE);
mButton.setText("make edit visiable");
} else {
mEditText.setVisibility(View.VISIBLE);
mButton.setText("make edit gone");
}
}
});
}
}
粘进去就好了 点一下EditText消失 再点一下就恢复
那个不是TextView 是EditText ,你只要把EditText放在Button上面就行了 代码如下:
粘进去运行就行了 activity随便写个就行 记得配manifest~~~