Hello,
I am trying to create a compound control using a TextView and Seekbar.
I am also trying to keep the SeekBar focused on itself during
View.FOCUS_RIGHT and View.FOCUS_LEFT transitions. If using just a seek
bar by itself I can add android:nextFocusRight(Left) to the layout.xml
which works. But when I pass focus to the seekbar in the compound
control it does not seem to work.
Any ideas on how to constrain the focus of a seek bar in a compound
control to only exit focus on View.FOCUS_UP or View.FOCUS_DOWN?
<mvis.pektroller.SeekBarLabeled
android:id="@+id/BrightnessBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="100"
android:nextFocusRight = "@+id/
BrightnessBar">
</mvis.pektroller.SeekBarLabeled >
public class SeekBarLabeled extends LinearLayout {
private static final String TAG = "SeekBarLabeled";
TextView textView;
SeekBar seekBarFocused;
...
public SeekBarLabeled(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater inflater = (LayoutInflater)getContext
().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.seek_bar_labeled, this);
view.setFocusable(true);
seekBarFocused = (SeekBar)findViewById(R.id.ValueBar);
textView = (TextView)findViewById(R.id.ValueText);
}
public void onFocusChanged(boolean gainFocus, int direction, Rect
previouslyFocusedRect) {
if (gainFocus) {
textView.setTextColor(Color.WHITE);
Log.v(TAG, "onFocusChangeListener() hasFocus.");
seekBarFocused.requestFocus();
} else {
textView.setTextColor(Color.LTGRAY);
Log.v(TAG, "onFocusChangeListener() !hasFocus.");
}
super.onFocusChanged(gainFocus, direction,
previouslyFocusedRect);
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en