List of usage examples for android.widget AdapterView isFocused
@ViewDebug.ExportedProperty(category = "focus") public boolean isFocused()
From source file:com.mstar.tv.tvplayer.philips.setting.SettingMainFragment.java
@Override public void onStart() { super.onStart(); listView = getListView();//from w w w .j ava 2 s . co m if (getFragmentManager().findFragmentById(R.id.first_fragment) != null) { listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } listView.setDivider(null); listView.setDividerHeight(5); listView.setSelector(android.R.color.transparent); listView.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mCallback.onMainSelectedData(position); if (parent.isFocused()) settingAdapter.setSelectViewPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); listView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { settingAdapter.setSelectViewPosition(listView.getSelectedItemPosition()); } else { settingAdapter.setSelectViewPosition(-1); } } }); listView.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (K_TvCommonManager.getInstance().K_getCurrentTvInputSource() != K_Constants.INPUT_SOURCE_ATV && K_TvCommonManager.getInstance() .K_getCurrentTvInputSource() != K_Constants.INPUT_SOURCE_DTV || SettingKarrays.isTopActivity(mContext, "com.android.mslauncher.LauncherActivity")) { if (listView.getSelectedItemPosition() == listView.getLastVisiblePosition() - 1 && keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { listView.setSelection(listView.getLastVisiblePosition() - 1); return true; } } return false; } }); }
From source file:com.mstar.tv.tvplayer.philips.setting.SettingFirstFragment.java
@Override public void onStart() { super.onStart(); listView = getListView();//from w w w .j av a2 s . c o m if (getFragmentManager().findFragmentById(R.id.first_fragment) != null) { listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); } listView.setDivider(null); listView.setDividerHeight(5); listView.setSelector(android.R.color.transparent); listView.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (parent.isFocused()) settingAdapter.setSelectViewPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); listView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { settingAdapter.setSelectViewPosition(getSelectedItemPosition()); } else { settingAdapter.setSelectViewPosition(-1); } } }); listView.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { if (TvSettingMenuActivity.firstSelectPositon == SettingKarrays.SETTING_PHOTO) { if (K_TvCommonManager.getInstance().K_getCurrentTvInputSource() == K_Constants.INPUT_SOURCE_VGA && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { if (listView.getSelectedItemPosition() == 2) { listView.setSelection(5); return true; } } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { if (listView.getSelectedItemPosition() == 5) { listView.setSelection(2); return true; } else if (listView.getSelectedItemPosition() == 1) { //listView.setSelection(1); return true; } } } } else if (TvSettingMenuActivity.firstSelectPositon == SettingKarrays.SETTING_TV) { if (!(mTvCommonManager.getCurrentTvInputSource() == TvCommonManager.INPUT_SOURCE_HDMI || mTvCommonManager.getCurrentTvInputSource() == TvCommonManager.INPUT_SOURCE_HDMI2 || mTvCommonManager.getCurrentTvInputSource() == TvCommonManager.INPUT_SOURCE_HDMI3)) {//EDID?? if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { if (listView.getSelectedItemPosition() == 4) { listView.setSelection(6); return true; } } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { if (listView.getSelectedItemPosition() == 6) { listView.setSelection(4); return true; } } } } return false; } }); }