I want to change EditText field for each spinner selection, my EditText field should be able to take input in Feet+inch or in Cms based on the input selected by user for unit's field, ie if User selects Metric System then EditText should change into cm format, for FPS system the EditText should change to Feet+inch format, something like following image
I guess I have to use onClickListener on spinner and then have to change EditText, but I don't know how to do that.
you should use this interface with your spinner. the 'position' corresponds to the spinner array item position, it your spinner array is ["inch","cm"] then case 0 correspond "inch" and 1 is "cm". I hope it will help.
//set spinner listener
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case 0:
//TODO change EditText
break;
case 1:
//TODO change EditText
break;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Thank you for your time I got what I wanted , I just used a workaround, I deploeyd three feilds Ft,In and cms; Ft for feet , In for inches and cms for centimeters, In spinner ft+in , and cms are two options, I set the visibility of non selected option as VISIBLE.GONE.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.