本文整理匯總了Java中android.widget.ListView.setSelector方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setSelector方法的具體用法?Java ListView.setSelector怎麽用?Java ListView.setSelector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListView
的用法示例。
在下文中一共展示了ListView.setSelector方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeCenterView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
@NonNull
protected LinearLayout makeCenterView() {
LinearLayout rootLayout = new LinearLayout(activity);
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
rootLayout.setBackgroundColor(Color.WHITE);
rootLayout.setOrientation(LinearLayout.VERTICAL);
ListView listView = new ListView(activity);
listView.setBackgroundColor(Color.WHITE);
listView.setDivider(new ColorDrawable(0xFFDDDDDD));
listView.setDividerHeight(1);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setSelector(R.color.itemSelected);
listView.setCacheColorHint(Color.TRANSPARENT);
listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
rootLayout.addView(listView);
return rootLayout;
}
示例2: FileListView
import android.widget.ListView; //導入方法依賴的package包/類
FileListView(Commander c)
{
commander = c;
listView = (ListView) commander.findViewById(R.id.fman_list_view);
listView.setItemsCanFocus(false);
listView.setFocusableInTouchMode(true);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setOnItemClickListener(this);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
{
TypedValue outValue = new TypedValue();
commander.getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground, outValue, true);
listView.setSelector(outValue.resourceId);
}
commander.registerForContextMenu(listView);
statusPanel = (LinearLayout) commander.findViewById(R.id.fman_status_panel);
statusPanelDivider = commander.findViewById(R.id.fman_status_panel_divider);
statusBar = (TextView) commander.findViewById(R.id.fman_status_bar);
}
示例3: onCreateView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View onCreateView() {
LinearLayout ll_container = new LinearLayout(context);
ll_container.setOrientation(LinearLayout.VERTICAL);
/** title */
tv_title = new TextView(context);
tv_title.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
tv_title.setSingleLine(true);
tv_title.setPadding(dp2px(18), dp2px(10), 0, dp2px(10));
ll_container.addView(tv_title);
/** listview */
lv = new ListView(context);
lv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
lv.setCacheColorHint(Color.TRANSPARENT);
lv.setFadingEdgeLength(0);
lv.setVerticalScrollBarEnabled(false);
lv.setSelector(new ColorDrawable(Color.TRANSPARENT));
ll_container.addView(lv);
return ll_container;
}
示例4: onCreate
import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Make activity fullscreen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
ActionBar supportActionBar = getSupportActionBar();
if (null != supportActionBar)
supportActionBar.hide();
setContentView(R.layout.ec_main_activity);
// Create adapter for pager
ECPagerViewAdapter adapter = new ECPagerViewAdapter(this, new ExampleDataset().getDataset()) {
@Override
public void instantiateCard(LayoutInflater inflaterService, ViewGroup head, ListView list, final ECCardData data) {
final CardData cardData = (CardData) data;
// Create adapter for list inside a card and set adapter to card content
CommentArrayAdapter commentArrayAdapter = new CommentArrayAdapter(getApplicationContext(), cardData.getListItems());
list.setAdapter(commentArrayAdapter);
list.setDivider(getResources().getDrawable(R.drawable.ec_list_divider));
list.setDividerHeight((int) pxFromDp(getApplicationContext(), 0.5f));
list.setSelector(R.color.ec_transparent);
list.setBackgroundColor(Color.WHITE);
list.setCacheColorHint(Color.TRANSPARENT);
// Add gradient to root header view
View gradient = new View(getApplicationContext());
gradient.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT));
gradient.setBackgroundDrawable(getResources().getDrawable(R.drawable.ec_card_head_gradient));
head.addView(gradient);
// Inflate main header layout and attach it to header root view
inflaterService.inflate(R.layout.ec_simple_head, head);
// Set header data from data object
TextView title = (TextView) head.findViewById(R.id.ec_title);
title.setText(cardData.getHeadTitle());
ImageView avatar = (ImageView) head.findViewById(R.id.ec_avatar);
avatar.setImageResource(cardData.getPersonPictureResource());
TextView name = (TextView) head.findViewById(R.id.ec_name);
name.setText(cardData.getPersonName() + ":");
TextView message = (TextView) head.findViewById(R.id.ec_message);
message.setText(cardData.getPersonMessage());
TextView viewsCount = (TextView) head.findViewById(R.id.ec_social_views_count);
viewsCount.setText(" " + cardData.getPersonViewsCount());
TextView likesCount = (TextView) head.findViewById(R.id.ec_social_likes_count);
likesCount.setText(" " + cardData.getPersonLikesCount());
TextView commentsCount = (TextView) head.findViewById(R.id.ec_social_comments_count);
commentsCount.setText(" " + cardData.getPersonCommentsCount());
// Add onclick listener to card header for toggle card state
head.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
ecPagerView.toggle();
}
});
}
};
ecPagerView = (ECPagerView) findViewById(R.id.ec_pager_element);
ecPagerView.setPagerViewAdapter(adapter);
ecPagerView.setBackgroundSwitcherView((ECBackgroundSwitcherView) findViewById(R.id.ec_bg_switcher_element));
final ItemsCountView itemsCountView = (ItemsCountView) findViewById(R.id.ec_items_count_view);
ecPagerView.setOnCardSelectedListener(new ECPagerView.OnCardSelectedListener() {
@Override
public void cardSelected(int newPosition, int oldPosition, int totalElements) {
itemsCountView.update(newPosition, oldPosition, totalElements);
}
});
}
示例5: onCreate
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle icicle) {
if (DBG) Log.d(TAG, "onCreate");
super.onCreate(icicle);
setContentView(R.layout.subtitles_wizard_main);
// Extract the path of the video to handle from the intent
Uri videoUri = getIntent().getData();
// FIXME: this is broken for smb:// files
if (videoUri != null) {
mVideoUri = videoUri;
mVideoPath = videoUri.getPath();
if (DBG) Log.d(TAG, "onCreate : video to process = " + mVideoPath);
if (mVideoPath != null) {
File videoFile = new File(mVideoPath);
// Retrieve the list of subtitles files already associated with the video
mCurrentFilesCount = buildCurrentSubtitlesFilesList(mVideoPath);
if (DBG) Log.d(TAG, "onCreate : mCurrentFilesCount = " + mCurrentFilesCount);
// Get the list of subtitles files available in the current folder
mAvailableFilesCount = buildAvailableSubtitlesFilesList(videoFile.getParent());
if (DBG) Log.d(TAG, "onCreate : mAvailableFilesCount = " + mAvailableFilesCount);
}
}
else {
// Bad intent
Log.e(TAG, "onCreate error : no folder provided");
mVideoUri = null;
}
// Use the name of the video to build the help message displayed at the top of the screen
TextView helpMessageHeader = (TextView) findViewById(R.id.help_message_header);
String name = Utils.getFileNameWithoutExtension(mVideoUri);
String helpMessage;
if (mAvailableFilesCount == 0 && mCurrentFilesCount == 0) {
helpMessage = getString(R.string.subtitles_wizard_empty_list_help).replace("%s", name);
}
else {
helpMessage = getString(R.string.subtitles_wizard_help).replace("%s", name);
}
helpMessageHeader.setText(helpMessage);
// Inflate the view to show if no subtitles files are found
mEmptyView = (TextView) LayoutInflater.from(this).inflate(R.layout.browser_empty_item, null);
mListView = (ListView) findViewById(R.id.list_items);
mListView.setEmptyView(mEmptyView);
SubtitlesWizardAdapter adapter = new SubtitlesWizardAdapter(getApplication(), this);
mListView.setAdapter(adapter);
mListView.setCacheColorHint(0);
mListView.setOnItemClickListener(this);
mListView.setOnCreateContextMenuListener(this);
mListView.setSelector(R.drawable.list_selector_no_background);
//mDefaultIconsColor = getResources().getColor(R.color.default_icons_color_filter);
// Handle the message to display when there are no files
enableEmptyView(mAvailableFilesCount == 0 && mCurrentFilesCount == 0);
}
示例6: onCreate
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL, LayoutParams.FLAG_NOT_TOUCH_MODAL);
getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
// Notify the application that the activity has started
CustomApplication app = (CustomApplication)getApplication();
app.setAutoScraperActive(true);
mScraper = new Scraper(this);
// Check if the intent which created this activity contains a folder path
Uri folderUri = getIntent().getData();
if (folderUri != null) {
mFolderMode = true;
// FIXME: this is broken for smb:// files
mFolderPath = folderUri.getPath();
if (DBG) Log.d(TAG, "onCreate : search in folder " + mFolderPath);
}
else {
mFolderMode = false;
mFolderPath = null;
if (DBG) Log.d(TAG, "onCreate : search in the full database");
}
setContentView(R.layout.auto_scraper_main);
mMainView = findViewById(R.id.main_view);
mAbortButton = (Button)findViewById(R.id.abort_button);
mAbortButton.setOnClickListener(this);
mExitButton = (Button)findViewById(R.id.exit_button);
mExitButton.setOnClickListener(this);
mListView = (ListView) findViewById(R.id.list_items);
mListView.setTextFilterEnabled(true);
mListView.setCacheColorHint(0);
mListView.setSelector(R.drawable.list_selector_no_background);
mListView.setOnCreateContextMenuListener(this);
mListView.setOnScrollListener(this);
mListView.setOnKeyListener(this);
mActivityFileCursor = getFileListCursor();
getColumnIndices(mActivityFileCursor);
buildFileProperties(mActivityFileCursor);
mAdapterFileCursor = buildAdapterCursor(mActivityFileCursor);
mAdapter = new AutoScraperAdapter(getApplication(), this,
R.layout.auto_scraper_item,
mAdapterFileCursor);
mListView.setAdapter(mAdapter);
/*
if (!mListView.isInTouchMode()) {
// The application is remotely controlled => set the focus by default
// on the Cancel button so that the user can abort the task with a
// single click instead of navigating the full ListView
mAbortButton.requestFocus();
}
*/
mEmptyView = buildEmptyView();
mListView.setEmptyView(mEmptyView);
updateControlButtons(false);
if (mFileCount > 0) {
mMainView.setVisibility(View.VISIBLE);
}
else {
mMainView.setVisibility(View.GONE);
}
mIsLargeScreen = getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)|| TVUtils.isTV(this);
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "AutoScraperActivity");
}