下面列出了android.widget.ListView#setFastScrollEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressLint("NewApi")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_list_cards, container, false);
mCastManager = CastApplication.getCastManager(this.getActivity());
mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
mProgressBar.setVisibility(View.VISIBLE);
mListView = (ListView) rootView.findViewById(android.R.id.list);
mListView.setAdapter(mAdapter);
mListView.setFastScrollEnabled(true);
mListView.setSmoothScrollbarEnabled(true);
mListView.setOnItemClickListener(this);
mEmptyView = (ViewStub) rootView.findViewById(android.R.id.empty);
mEmptyView.setOnInflateListener(this);
return rootView;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setupVariables();
View v = inflater.inflate(R.layout.overview_list, container, false);
list = (ListView) v.findViewById(R.id.list);
list.setFastScrollEnabled(true);
setupAdapter();
if (savedInstanceState == null) {
animateToolbar();
postponeEnterTransition();
}
setEnterTransition(new Slide(Gravity.LEFT));
setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.image_shared_element_transition));
return v;
}
public void show(final int selected) {
if (listAdapter == null) {
return;
}
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
dialog = builder.setSingleChoiceItems(listAdapter, 0, this).create();
dialog.setCanceledOnTouchOutside(true);
final ListView listView = dialog.getListView();
listView.setFastScrollEnabled(true);
listView.setScrollbarFadingEnabled(false);
listView.postDelayed(new Runnable() {
@Override
public void run() {
listView.setSelection(selected);
}
}, DELAY_MILLIS);
dialog.show();
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
lvTheme = (ListView) findViewById(R.id.lvTheme);
TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(lvTheme);
ThemeUtil.setListViewStyle(lvTheme);
tvTitle.setText(R.string.title_theme);
Intent intent = this.getIntent();
account = (LocalAccount)intent.getSerializableExtra("ACCOUNT");
if (account == null) {
account = sheJiaoMao.getCurrentAccount();
}
adapter = new ThemeListAdapter(this, account);
lvTheme.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
//showLoadingFooter();
lvTheme.setAdapter(adapter);
themeRecyclerListener = new ThemeRecyclerListener();
lvTheme.setRecyclerListener(themeRecyclerListener);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View result = inflater.inflate(R.layout.list, null);
mListView = (ListView)result.findViewById(R.id.listView);
mAdapter = new ArrayAdapter<String>(getActivity(),
R.layout.list_item_multiple_choice,
android.R.id.text1,
getResources().getStringArray(R.array.list_items));
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(this);
mListView.setMultiChoiceModeListener(mMultiChoiceModeListener);
mListView.setFastScrollEnabled(true);
mListView.setFastScrollAlwaysVisible(true);
setHasOptionsMenu(true);
return result;
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(lvMicroBlog);
ThemeUtil.setListViewStyle(lvMicroBlog);
user = (User)this.getIntent().getSerializableExtra("USER");
if (user == null) {
return;
}
TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle);
tvTitle.setText(user.getScreenName());
adapter = new MyStatusesListAdapter(this, sheJiaoMao.getCurrentAccount());
showMoreFooter();
lvMicroBlog.setAdapter(adapter);
lvMicroBlog.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
setBack2Top(lvMicroBlog);
recyclerListener = new StatusRecyclerListener();
lvMicroBlog.setRecyclerListener(recyclerListener);
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
lvMicroBlog = (ListView) this.findViewById(R.id.lvMicroBlog);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(lvMicroBlog);
ThemeUtil.setListViewStyle(lvMicroBlog);
TextView tvTitle = ((TextView) this.findViewById(R.id.tvTitle));
tvTitle.setText(R.string.title_favorites);
lvMicroBlog.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
showMoreFooter();
lvMicroBlog.setAdapter(adapter);
setBack2Top(lvMicroBlog);
recyclerListener = new StatusRecyclerListener();
lvMicroBlog.setRecyclerListener(recyclerListener);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Intent intent = getActivity().getIntent();
final String localeFromIntent =
null == intent ? null : intent.getStringExtra("locale");
final Bundle arguments = getArguments();
final String localeFromArguments =
null == arguments ? null : arguments.getString("locale");
final String locale;
if (null != localeFromArguments) {
locale = localeFromArguments;
} else locale = localeFromIntent;
mLocale = locale;
// WARNING: The following cursor is never closed! TODO: don't put that in a member, and
// make sure all cursors are correctly closed. Also, this comes from a call to
// Activity#managedQuery, which has been deprecated for a long time (and which FORBIDS
// closing the cursor, so take care when resolving this TODO). We should either use a
// regular query and close the cursor, or switch to a LoaderManager and a CursorLoader.
mCursor = createCursor(locale);
TextView emptyView = getView().findViewById(android.R.id.empty);
emptyView.setText(R.string.user_dict_settings_empty_text);
final ListView listView = getListView();
listView.setAdapter(createAdapter());
listView.setFastScrollEnabled(true);
listView.setEmptyView(emptyView);
setHasOptionsMenu(true);
// Show the language as a subtitle of the action bar
getActivity().getActionBar().setSubtitle(
UserDictionarySettingsUtils.getLocaleDisplayName(getActivity(), mLocale));
}
/**
* Prepare ListView with added data. Set IconedListAdapter as adapter, second line to visible and
* fast scroll if more then 50 items in adapter array.
*
* @param context
* @param lv
* @param adapterData
*/
public static void setListView(Context context, ListView lv, boolean setMultiple,
ArrayList<DataInfo> adapterData) {
if (setMultiple)
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
IconedListAdapter adapter = new IconedListAdapter(context, adapterData, lv);
adapter.setTextView02Visible(View.VISIBLE, true);
if (adapterData.size() > 50)
lv.setFastScrollEnabled(true);
lv.setAdapter(adapter);
}
public void selectPageDialog() {
if (context == null)
context = App.getActivity();
final int[] pages = new int[pagination.getAll()];
for (int i = 0; i < pagination.getAll(); i++)
pages[i] = i + 1;
final ListView listView = new ListView(context);
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setFastScrollEnabled(true);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setAdapter(new PaginationAdapter(context, pages));
listView.setItemChecked(pagination.getCurrent() - 1, true);
listView.setSelection(pagination.getCurrent() - 1);
AlertDialog dialog = new AlertDialog.Builder(context)
.setView(listView)
.show();
if (dialog.getWindow() != null)
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
listView.setOnItemClickListener((adapterView, view1, i2, l) -> {
if (listView.getTag() != null && !((Boolean) listView.getTag())) {
return;
}
selectPage(i2 * pagination.getPerPage());
dialog.cancel();
});
}
private void initComponents() {
LinearLayout llRoot = (LinearLayout)this.findViewById(R.id.llRoot);
LinearLayout llHeaderBase = (LinearLayout)this.findViewById(R.id.llHeaderBase);
LinearLayout llTabHeader = (LinearLayout)this.findViewById(R.id.llTabHeader);
lvUser = (ListView)this.findViewById(R.id.lvUser);
ThemeUtil.setRootBackground(llRoot);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setHeaderToggleTab(llTabHeader);
ThemeUtil.setListViewStyle(lvUser);
Intent intent = this.getIntent();
user = (User)intent.getSerializableExtra("USER");
if (user == null) {
return;
}
tabType = intent.getIntExtra("TAB_TYPE", TAB_TYPE_ALL);
TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle);
String title = this.getString(R.string.title_group, user.getFriendsCount());
tvTitle.setText(title);
btnTabLeft = (Button) this.findViewById(R.id.btnTabLeft);
btnTabLeft.setText(R.string.label_tab_all);
btnTabRight = (Button) this.findViewById(R.id.btnTabRight);
btnTabRight.setText(R.string.label_tab_group);
lvUser.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
userRecyclerListener = new UserRecyclerListener();
lvUser.setRecyclerListener(userRecyclerListener);
setBack2Top(lvUser);
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
mAdapter.swapCursor(data);
ListView lv = getListView();
lv.setFastScrollEnabled(true);
lv.setFastScrollAlwaysVisible(true);
if (isTwoPane()){
lv.setVerticalScrollbarPosition(ListView.SCROLLBAR_POSITION_LEFT);
lv.setPadding(15, 0, 0, 0);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View v = inflater.inflate(R.layout.layout_list, container,false);
listView = (ListView) v.findViewById(android.R.id.list);
listView.setFastScrollEnabled(true);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
registerForContextMenu(listView);
listView.setMultiChoiceModeListener(new ListViewMultiChoiceModeListener(
mContext,getActivity(),
listView,mRoot,
mCpu,
mGpu,
mUv,
mKernel,
mLmk,
mGov,
mSched,
mQuiet,
mVm,
db,
VddDb,
true));
return v;
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(lvMicroBlog);
ThemeUtil.setListViewStyle(lvMicroBlog);
Intent intent = this.getIntent();
type = intent.getIntExtra("STATUS_CATALOG", StatusCatalog.Hot_Retweet.getCatalogNo());
TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle);
int titleId = R.string.title_hot_retweets;
if (type == StatusCatalog.Hot_Comment.getCatalogNo()) {
titleId = R.string.title_hot_comments;
}
tvTitle.setText(titleId);
adapter = new HotStatusesListAdapter(this, sheJiaoMao.getCurrentAccount());
showMoreFooter();
lvMicroBlog.setAdapter(adapter);
lvMicroBlog.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
lvMicroBlog.setOnScrollListener(new StatusScrollListener());
setBack2Top(lvMicroBlog);
recyclerListener = new StatusRecyclerListener();
lvMicroBlog.setRecyclerListener(recyclerListener);
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
lvUser = (ListView) findViewById(R.id.lvUser);
TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(lvUser);
ThemeUtil.setListViewStyle(lvUser);
Intent intent = this.getIntent();
socialGraphType = intent.getIntExtra("SOCIAL_GRAPH_TYPE", socialGraphType);
user = (User)intent.getSerializableExtra("USER");
if (user == null) {
return;
}
account = (LocalAccount)intent.getSerializableExtra("ACCOUNT");
if (account == null) {
account = sheJiaoMao.getCurrentAccount();
}
adapter = new SocialGraphListAdapter(this, account, socialGraphType);
lvUser.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
showLoadingFooter();
lvUser.setAdapter(adapter);
userRecyclerListener = new UserRecyclerListener();
lvUser.setRecyclerListener(userRecyclerListener);
setBack2Top(lvUser);
if (socialGraphType == SocialGraphTask.TYPE_FOLLOWERS) {
tvTitle.setText(R.string.title_followers);
} else if (socialGraphType == SocialGraphTask.TYPE_FRIENDS) {
tvTitle.setText(R.string.title_friends);
} else if (socialGraphType == SocialGraphTask.TYPE_BLOCKS) {
tvTitle.setText(R.string.title_blocks);
}
}
private void initComponents() {
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
ThemeUtil.setSecondaryHeader(llHeaderBase);
ThemeUtil.setContentBackground(lvMicroBlog);
ThemeUtil.setListViewStyle(lvMicroBlog);
int temp = getIntent().getIntExtra("STATUS_CATALOG",
StatusCatalog.News.getCatalogNo());
catalog = StatusCatalog.getStatusCatalog(temp);
if (catalog == null) {
return;
}
int titleId = getIntent().getIntExtra("TITLE_ID", R.string.label_app_daily);
TextView tvTitle = (TextView)this.findViewById(R.id.tvTitle);
tvTitle.setText(titleId);
adapter = new StatusSubscribeListAdapter(this, sheJiaoMao.getCurrentAccount());
showMoreFooter();
lvMicroBlog.setAdapter(adapter);
lvMicroBlog.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
lvMicroBlog.setOnScrollListener(new StatusScrollListener());
setBack2Top(lvMicroBlog);
recyclerListener = new StatusRecyclerListener();
lvMicroBlog.setRecyclerListener(recyclerListener);
}
private void initComponents() {
LinearLayout llRoot = (LinearLayout)this.findViewById(R.id.llRoot);
LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
LinearLayout llHeaderSearch = (LinearLayout)findViewById(R.id.llHeaderSearch);
EditText etKeyWord = (EditText) findViewById(R.id.etKeyWord);
Button btnSearch = (Button) findViewById(R.id.btnSearch);
btnSearchStatus = (Button) findViewById(R.id.btnSearchStatus);
btnSearchUser = (Button) findViewById(R.id.btnSearchUser);
lvSearchResult = (ListView) findViewById(R.id.lvSearchResult);
lvSearchResult.setFastScrollEnabled(sheJiaoMao.isSliderEnabled());
lvSearchResult.setOnScrollListener(new StatusScrollListener());
ThemeUtil.setRootBackground(llRoot);
ThemeUtil.setSecondaryHeader(llHeaderBase);
llHeaderSearch.setBackgroundDrawable(theme.getDrawable("bg_header_corner_search"));
int padding6 = theme.dip2px(6);
int padding8 = theme.dip2px(8);
llHeaderSearch.setPadding(padding6, padding8, padding6, padding8);
ThemeUtil.setListViewStyle(lvSearchResult);
etKeyWord.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half"));
btnSearch.setBackgroundDrawable(theme.getDrawable("selector_btn_search"));
btnSearchStatus.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_left"));
btnSearchStatus.setPadding(0, 0, 0, 0);
ColorStateList selectorBtnTab = theme.getColorStateList("selector_btn_tab");
btnSearchStatus.setTextColor(selectorBtnTab);
btnSearchStatus.setGravity(Gravity.CENTER);
btnSearchUser.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_right"));
btnSearchUser.setPadding(0, 0, 0, 0);
btnSearchUser.setTextColor(selectorBtnTab);
btnSearchUser.setGravity(Gravity.CENTER);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Intent intent = getActivity().getIntent();
final String localeFromIntent =
null == intent ? null : intent.getStringExtra("locale");
final Bundle arguments = getArguments();
final String localeFromArguments =
null == arguments ? null : arguments.getString("locale");
final String locale;
if (null != localeFromArguments) {
locale = localeFromArguments;
} else if (null != localeFromIntent) {
locale = localeFromIntent;
} else {
locale = null;
}
mLocale = locale;
// WARNING: The following cursor is never closed! TODO: don't put that in a member, and
// make sure all cursors are correctly closed. Also, this comes from a call to
// Activity#managedQuery, which has been deprecated for a long time (and which FORBIDS
// closing the cursor, so take care when resolving this TODO). We should either use a
// regular query and close the cursor, or switch to a LoaderManager and a CursorLoader.
mCursor = createCursor(locale);
TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
emptyView.setText(R.string.user_dict_settings_empty_text);
final ListView listView = getListView();
listView.setAdapter(createAdapter());
listView.setFastScrollEnabled(true);
listView.setEmptyView(emptyView);
setHasOptionsMenu(true);
// Show the language as a subtitle of the action bar
getActivity().getActionBar().setSubtitle(
UserDictionarySettingsUtils.getLocaleDisplayName(getActivity(), mLocale));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.dialer_digit, container, false);
// Store the backgrounds objects that will be in use later
/*
Resources r = getResources();
digitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active);
digitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield_normal);
*/
// Store some object that could be useful later
digits = (DigitsEditText) v.findViewById(R.id.digitsText);
dialPad = (Dialpad) v.findViewById(R.id.dialPad);
callBar = (DialerCallBar) v.findViewById(R.id.dialerCallBar);
autoCompleteList = (ListView) v.findViewById(R.id.autoCompleteList);
rewriteTextInfo = (TextView) v.findViewById(R.id.rewriteTextInfo);
accountChooserButton = (AccountChooserButton) v.findViewById(R.id.accountChooserButton);
accountChooserFilterItem = accountChooserButton.addExtraMenuItem(R.string.apply_rewrite);
accountChooserFilterItem.setCheckable(true);
accountChooserFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
setRewritingFeature(!accountChooserFilterItem.isChecked());
return true;
}
});
setRewritingFeature(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.REWRITE_RULES_DIALER));
dialerLayout = (DialerLayout) v.findViewById(R.id.top_digit_dialer);
//switchTextView = (ImageButton) v.findViewById(R.id.switchTextView);
// isTablet = Compatibility.isTabletScreen(getActivity());
// Digits field setup
if(savedInstanceState != null) {
isDigit = savedInstanceState.getBoolean(TEXT_MODE_KEY, isDigit);
}
digits.setOnEditorActionListener(keyboardActionListener);
// Layout
dialerLayout.setForceNoList(mDualPane);
dialerLayout.setAutoCompleteListVisibiltyChangedListener(this);
// Account chooser button setup
accountChooserButton.setShowExternals(true);
accountChooserButton.setOnAccountChangeListener(accountButtonChangeListener);
// Dialpad
dialPad.setOnDialKeyListener(this);
// We only need to add the autocomplete list if we
autoCompleteList.setAdapter(autoCompleteAdapter);
autoCompleteList.setOnItemClickListener(autoCompleteListItemListener);
autoCompleteList.setFastScrollEnabled(true);
// Bottom bar setup
callBar.setOnDialActionListener(this);
callBar.setVideoEnabled(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_VIDEO));
//switchTextView.setVisibility(Compatibility.isCompatible(11) ? View.GONE : View.VISIBLE);
// Init other buttons
initButtons(v);
// Ensure that current mode (text/digit) is applied
setTextDialing(!isDigit, true);
if(initText != null) {
digits.setText(initText);
initText = null;
}
// Apply third party theme if any
applyTheme(v);
v.setOnKeyListener(this);
applyTextToAutoComplete();
return v;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final Intent intent = getActivity().getIntent();
final String localeFromIntent =
null == intent ? null : intent.getStringExtra("locale");
final Bundle arguments = getArguments();
final String localeFromArguments =
null == arguments ? null : arguments.getString("locale");
final String locale;
if (null != localeFromArguments) {
locale = localeFromArguments;
} else if (null != localeFromIntent) {
locale = localeFromIntent;
} else {
locale = null;
}
mLocale = locale;
// WARNING: The following cursor is never closed! TODO: don't put that in a member, and
// make sure all cursors are correctly closed. Also, this comes from a call to
// Activity#managedQuery, which has been deprecated for a long time (and which FORBIDS
// closing the cursor, so take care when resolving this TODO). We should either use a
// regular query and close the cursor, or switch to a LoaderManager and a CursorLoader.
mCursor = createCursor(locale);
TextView emptyView = (TextView) getView().findViewById(android.R.id.empty);
emptyView.setText(R.string.user_dict_settings_empty_text);
final ListView listView = getListView();
listView.setAdapter(createAdapter());
listView.setFastScrollEnabled(true);
listView.setEmptyView(emptyView);
setHasOptionsMenu(true);
// Show the language as a subtitle of the action bar
getActivity().getActionBar().setSubtitle(
UserDictionarySettingsUtils.getLocaleDisplayName(getActivity(), mLocale));
}