通常、私はXMLでそれを行うか、My Edittextが非表示になります。表示されたときに編集可能にするにはどうすればよいですか?
.setEnabled(true);
でコードから、それを設定するが、私はそれがこのケースで働いて得ることができないと思います。簡単に言えば、EditText
は不可視に設定されており、CheckBox
クリックすると表示が消えて編集可能になるはずですが...そうではありません。 EditText
は意図したとおりにフェードインしてフェードアウトしますが、テキストをボックスに入力することはできません。どうしたらいいですか?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.addcontact);
// initialise the edittexts
textcategory = (EditText) findViewById(R.id.textCategory);
textcategory.setVisibility(View.INVISIBLE);
fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
fadeOutAnimation = AnimationUtils.loadAnimation(this, R.anim.fadeout);
// lets be able to manipuate checkbox,
// make other things visible or not when checked
checkBox = (CheckBox) findViewById(R.id.checkBox);
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
// Now Set your animation
textcategory.startAnimation(fadeInAnimation);
fadeInAnimation.setFillAfter(true);
} else {
// Now Set your animation
textcategory.startAnimation(fadeOutAnimation);
}
}
});
}
そして、私のXML::アニメーション終了後
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:hint="Select a Category"
android:textSize="18sp"
android:layout_marginBottom="10dp"
android:id="@+id/textCategory"
android:background="@drawable/back"
android:layout_below="@+id/checkBox"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
としてViewPropertyAnimationを使用することができますアニメーションのためにあなたの活動
からこの行を削除し、この行を追加します。あなたはedittextのコードを書いています表示、非表示、編集可能ですか? – Vickyexpert
View.INVISIBLEの代わりにView.GONEを使用してください。 – Array
@Array。私はそれが問題を解決するとは思わない。 View.GONEは、私のEditTextがまったく存在しないのと同じように、他のビューがそのスペースを占めるようにします。 View.INVISIBLEはプレースホルダに似ていますが、ビューを見ることはできませんが、XMLまたはJavaコードで設定された領域を占有します。 – CHarris