Java Code Examples for android.widget.ListView.setSelector()

The following are Jave code examples for showing how to use setSelector() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: MainCalendar   File: FilePicker.java   View Source Code Vote up 6 votes
@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;
}
 
Example 2
Project: microMathematics   File: FileListView.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: Shared-Route   File: NormalListDialog.java   View Source Code Vote up 5 votes
@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;
}
 
Example 4
Project: showroom-android   File: ExpandingCollectionActivity.java   View Source Code Vote up 4 votes
@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);
        }
    });
}
 
Example 5
Project: aos-Video   File: SubtitlesWizardActivity.java   View Source Code Vote up 4 votes
@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);
}
 
Example 6
Project: aos-Video   File: AutoScraperActivity.java   View Source Code Vote up 4 votes
@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");
    }