Spinner set selection delayed
This commit is contained in:
parent
746d71bcff
commit
869b3eff5f
1 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.utils;
|
package info.nightscout.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.widget.TextViewCompat;
|
import android.support.v4.widget.TextViewCompat;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -260,7 +261,7 @@ public class TimeListEdit {
|
||||||
return childview;
|
return childview;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillSpinner(SpinnerHelper spinner, int secondsFromMidnight, int previous, int next) {
|
private void fillSpinner(final SpinnerHelper spinner, int secondsFromMidnight, int previous, int next) {
|
||||||
int posInList = 0;
|
int posInList = 0;
|
||||||
ArrayList<CharSequence> timeList = new ArrayList<>();
|
ArrayList<CharSequence> timeList = new ArrayList<>();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -270,10 +271,16 @@ public class TimeListEdit {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(context,
|
final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(context,
|
||||||
R.layout.spinner_centered, timeList);
|
R.layout.spinner_centered, timeList);
|
||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
spinner.setSelection(posInList, false);
|
final int finalPosInList = posInList;
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
spinner.setSelection(finalPosInList, false);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int itemsCount() {
|
private int itemsCount() {
|
||||||
|
|
Loading…
Reference in a new issue