本文整理了Java中android.widget.ListView.requestFocus()
方法的一些代码示例,展示了ListView.requestFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.requestFocus()
方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:requestFocus
暂无
代码示例来源:origin: stackoverflow.com
ListView list_view = getListView();
list_view.requestFocus();
list_view.setSelection(0);
代码示例来源:origin: stackoverflow.com
ListView listView = findViewById(R.id.list);
listView.setFocusableInTouchMode(true);
listView.requestFocus();
代码示例来源:origin: sh0/kotoba-android
public void Search(String query)
{
// Save query string
m_state_query = query;
// Search
ArrayList<SearchWord> result = m_search.Search(query);
m_result_adapter = new SearchAdapter(result);
m_result_view.setAdapter(m_result_adapter);
// Focus
m_result_view.requestFocus();
}
}
代码示例来源:origin: RWebRTC/WebRTC-Android-Learn
@Override
public void onResume() {
super.onResume();
String room = sharedPref.getString(keyprefRoom, "");
roomEditText.setText(room);
roomList = new ArrayList<String>();
String roomListJson = sharedPref.getString(keyprefRoomList, null);
if (roomListJson != null) {
try {
JSONArray jsonArray = new JSONArray(roomListJson);
for (int i = 0; i < jsonArray.length(); i++) {
roomList.add(jsonArray.get(i).toString());
}
} catch (JSONException e) {
Log.e(TAG, "Failed to load room list: " + e.toString());
}
}
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, roomList);
roomListView.setAdapter(adapter);
if (adapter.getCount() > 0) {
roomListView.requestFocus();
roomListView.setItemChecked(0, true);
}
}
代码示例来源:origin: stackoverflow.com
private void setupListViewAdapter(ListView listView, View headerView, View footerView){
listView.setDividerHeight(5);
listView.setFadingEdgeLength(200);
listView.addHeaderView(headerView, null, false);//--> here is another assignment
listView.addFooterView(footerView, null, false);//--> here is another assignment
listView.setScrollingCacheEnabled(false);
listView.requestFocus(0);
listView.setAdapter(mDataAdapter);
}
代码示例来源:origin: andforce/Maps
mListView.requestFocus();
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
代码示例来源:origin: hedzr/android-file-chooser
private boolean doMoveUp() {
if (_list.hasFocus()) {
Log.d("z", "move up at " + _adapter.getHoveredIndex());
int indexOld = _adapter.getHoveredIndex();
int index = _adapter.decreaseHoveredIndex();
if (indexOld >= 0 && indexOld != index) {
UiUtil.ensureVisible(_list, index);
_list.requestFocus();
} else {
_list.setSelection(index); // to prevent the list scroll to top.
moveFocusToButtons();
}
} else if (buttonsHasFocus()) {
_list.requestFocus();
}
return true;
}
代码示例来源:origin: hedzr/android-file-chooser
private boolean doMoveDown() {
if (_list.hasFocus()) {
Log.d("z", "move down at " + _adapter.getHoveredIndex());
int indexOld = _adapter.getHoveredIndex();
int index = _adapter.increaseHoveredIndex();
if (indexOld >= 0 && indexOld != index) {
UiUtil.ensureVisible(_list, index);
_list.requestFocus();
} else {
_list.setSelection(index); // to prevent the list scroll to top.
moveFocusToButtons();
}
} else if (buttonsHasFocus()) {
_list.requestFocus();
}
return true;
}
代码示例来源:origin: rogerta/secrets-for-android
@Override
protected void onNewIntent(Intent intent) {
// This method is invoked when the user performs a search from the global
// search dialog. It is called each time the user presses the "Done"
// button on the search keyboard.
// Get the search string. Make it a full text search by ensuring the
// string begins with a dot.
setIntent(intent);
String filter = intent.getStringExtra(SearchManager.QUERY);
if (filter.charAt(0) != SecretsListAdapter.DOT)
filter = SecretsListAdapter.DOT + filter;
getListView().setFilterText(filter);
// Try to hide the soft keyboard, if present. On some devices, setting
// focus to a view that does not support keyboard input is enough. On
// other devices where the the input method manager is implemented, try
// to hide the keyboard explicitly.
getListView().requestFocus();
OS.hideSoftKeyboard(this, getListView());
allowNextResume = true;
}
代码示例来源:origin: sh0/kotoba-android
private void UiSentences()
{
// Sentence tab visiblity
if (!m_state_sentence_active) {
// Sentences not visible
m_view_question_root.requestFocus();
m_view_question_root.setVisibility(View.VISIBLE);
m_view_sentence_list.setVisibility(View.GONE);
} else {
// Sentences visible
m_view_sentence_list.requestFocus();
m_view_sentence_list.setVisibility(View.VISIBLE);
m_view_question_root.setVisibility(View.GONE);
// Check if already set
if (!m_sentence_set) {
// Last question
DataTrainQuestion last = m_train.Last();
if (last == null)
return;
// Word
WordTrain word = last.WordQuestion();
if (word == null)
return;
// Set word reference
m_list_sentence.SetSref(word.Info().SrefArray());
// Mark as set
m_sentence_set = true;
}
}
}
代码示例来源:origin: hedzr/android-file-chooser
File file = _entries.get(position);
if (file.getName().equals("..")) {
if (!_list.hasFocus()) _list.requestFocus();
doGoBack();
return;
代码示例来源:origin: geniusgithub/AndroidDialer
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
onCreateView(inflater, container);
boolean searchMode = isSearchMode();
mAdapter.setSearchMode(searchMode);
mAdapter.configureDefaultPartition(false, searchMode);
mAdapter.setPhotoLoader(mPhotoManager);
mListView.setAdapter(mAdapter);
if (!isSearchMode()) {
mListView.setFocusableInTouchMode(true);
mListView.requestFocus();
}
return mView;
}
代码示例来源:origin: stackoverflow.com
lv.requestFocus();
代码示例来源:origin: rogerta/secrets-for-android
@Override
public void onAnimationEnd(Animation animation) {
if (AdapterView.INVALID_POSITION != editingPosition) {
ListView listView = getListView();
listView.requestFocus();
int first = listView.getFirstVisiblePosition();
int last = listView.getLastVisiblePosition();
if (editingPosition < first || editingPosition > last) {
listView.setSelection(editingPosition);
}
}
setTitle();
if (1 == secretsList.getAllSecrets().size()) {
showToast(getText(R.string.list_instructions));
}
}
代码示例来源:origin: qiubiteme/android_api_demos
public void run() {
final float centerX = mContainer.getWidth() / 2.0f;
final float centerY = mContainer.getHeight() / 2.0f;
Rotate3dAnimation rotation;
if (mPosition > -1) {
mPhotosList.setVisibility(View.GONE);
mImageView.setVisibility(View.VISIBLE);
mImageView.requestFocus();
rotation = new Rotate3dAnimation(90, 180, centerX, centerY, 310.0f, false);
} else {
mImageView.setVisibility(View.GONE);
mPhotosList.setVisibility(View.VISIBLE);
mPhotosList.requestFocus();
rotation = new Rotate3dAnimation(90, 0, centerX, centerY, 310.0f, false);
}
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new DecelerateInterpolator());
mContainer.startAnimation(rotation);
}
}
代码示例来源:origin: li2/learning-android-open-source
public void run() {
final float centerX = mContainer.getWidth() / 2.0f;
final float centerY = mContainer.getHeight() / 2.0f;
Rotate3dAnimation rotation;
if (mPosition > -1) {
mPhotosList.setVisibility(View.GONE);
mImageView.setVisibility(View.VISIBLE);
mImageView.requestFocus();
rotation = new Rotate3dAnimation(90, 180, centerX, centerY, 310.0f, false);
} else {
mImageView.setVisibility(View.GONE);
mPhotosList.setVisibility(View.VISIBLE);
mPhotosList.requestFocus();
rotation = new Rotate3dAnimation(90, 0, centerX, centerY, 310.0f, false);
}
rotation.setDuration(500);
rotation.setFillAfter(true);
rotation.setInterpolator(new DecelerateInterpolator());
mContainer.startAnimation(rotation);
}
}
代码示例来源:origin: TUM-Dev/Campus-Android
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_timetable_widget_configure);
// Setup toolbar and save button
setSupportActionBar(findViewById(R.id.main_toolbar));
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Drawable closeIcon = ContextCompat.getDrawable(this, R.drawable.ic_check);
if (closeIcon != null) {
int color = ContextCompat.getColor(this, R.color.color_primary);
closeIcon.setTint(color);
}
getSupportActionBar().setHomeAsUpIndicator(closeIcon);
}
// Get appWidgetId from intent
Bundle extras = getIntent().getExtras();
if (extras != null) {
appWidgetId = extras.getInt(
AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
}
ListView listViewLectures = findViewById(R.id.activity_timetable_lectures);
// Initialize stations adapter
CalendarController calendarController = new CalendarController(this);
List<CalendarItem> lectures = calendarController.getLecturesForWidget(this.appWidgetId);
listViewLectures.setAdapter(new LectureListSelectionAdapter(this, lectures, this.appWidgetId));
listViewLectures.requestFocus();
}
内容来源于网络,如有侵权,请联系作者删除!