Example usage for android.widget ListView setItemsCanFocus

List of usage examples for android.widget ListView setItemsCanFocus

Introduction

In this page you can find the example usage for android.widget ListView setItemsCanFocus.

Prototype

public void setItemsCanFocus(boolean itemsCanFocus) 

Source Link

Document

Indicates that the views created by the ListAdapter can contain focusable items.

Usage

From source file:com.roamprocess1.roaming4world.ui.calllog.CallLogListFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    System.out.println("CallLogListFragment oncreate View");

    // View management
    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    System.out.println("CallLogListFragment Step 3");

    // Modify list view
    ListView lv = getListView();
    System.out.println("CallLogListFragment Step 4");

    lv.setVerticalFadingEdgeEnabled(true);

    System.out.println("CallLogListFragment Step 4");

    lv_missedcall = (ListView) v.findViewById(R.id.lv_missed_Calls);

    // lv.setCacheColorHint(android.R.color.transparent);
    if (mDualPane) {
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        System.out.println("CallLogListFragment Step 5");

        lv.setItemsCanFocus(false);
    } else {//w  ww .  j av a2s  .c  o m
        lv.setChoiceMode(ListView.CHOICE_MODE_NONE);
        System.out.println("CallLogListFragment Step 6");

        lv.setItemsCanFocus(true);
    }

    // Map long press
    lv.setLongClickable(true);/*
                              lv.setOnItemLongClickListener(new OnItemLongClickListener() {
                                      
                              @Override
                              public boolean onItemLongClick(AdapterView<?> ad, View v, int pos, long id) {
                              turnOnActionMode();
                                      
                              System.out.println("CallLogListFragment Step 8"); 
                                      
                              getListView().setItemChecked(pos, true);
                              mMode.invalidate();
                              return true;
                              }
                              });*/
}

From source file:org.videolan.vlc.gui.VLCMainActivity.java

private void popupStreamingList(final MultiRoom mRoom, final ArrayList<String> roomList) {

    final View v = getLayoutInflater().inflate(R.layout.streamingroom_list, null, false);
    int h = getWindowManager().getDefaultDisplay().getHeight();
    int w = getWindowManager().getDefaultDisplay().getWidth();

    popRoomList = new PopupWindow(v, w - 10, (int) (((2.8) * h) / 4));
    popRoomList.setAnimationStyle(R.style.MyDialogStyleBottom);
    popRoomList.setFocusable(true);/*from w  w w . j  a  v a  2  s  . c om*/
    popRoomList.setBackgroundDrawable(new BitmapDrawable());
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            popRoomList.showAtLocation(v, Gravity.BOTTOM, 0, 0);
        }
    }, 500L);

    ArrayAdapter<String> roomAdapter = new ArrayAdapter<String>(this, R.layout.streamingroom_list_background,
            R.id.text1, roomList);
    ListView roomlistView = (ListView) v.findViewById(R.id.roomlist);
    roomlistView.setItemsCanFocus(true);
    //      roomlistView.setCacheColorHint(Color.TRANSPARENT);
    roomlistView.setAdapter(roomAdapter);
    roomlistView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            if (p != null) {

                /** rejoin the chat Room*/
                MultiUserChat muc = new MultiUserChat(connection, roomList.get(position) + "@" + serviceName);
                try {
                    //TODO 4: require password >>>>>>>>>>>>>>>>>>>>.

                    muc.join(connection.getUser(), p);

                    Log.i("VLCMainActivity--p", p);
                    Log.i("VLCMainActivity--rejoin user", connection.getUser());
                } catch (XMPPException e) {
                    //e.printStackTrace();
                }

                // set new chat room
                if (mRoom.getChatRoom() == null) {
                    mRoom.setChatRoom(roomList.get(position));
                    Log.i("VLCMainActivity--get room", "null");
                }

                /** request video streaming*/
                AudioServiceController audioServiceController = AudioServiceController.getInstance();
                // use audio as default player...
                String mAddress = mSettings.getString("key_server_address", null);
                String mPort = mSettings.getString("key_server_port", null);
                String streaminglink = "rtsp://" + mAddress + ":" + mPort + "/" + roomList.get(position)
                        + ".sdp";
                Log.i("VLCMainActivity--request streaminglink", streaminglink);
                audioServiceController.load(streaminglink, false);

                popRoomList.dismiss();

            } else {

                popRoomList.dismiss();
                Toast.makeText(getApplicationContext(), "Can't join because of No password", Toast.LENGTH_SHORT)
                        .show();
            }

        }

    });
}

From source file:org.openremote.android.console.AppSettingsActivity.java

/**
 * Auto discovery servers and add them in a list view.
 * Click a list item and make it as current server.
 * //from  ww w  .  ja  va  2s.  co  m
 * @return the list view
 */
private ListView constructAutoServersView() {
    final ListView lv = new ListView(this);
    lv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200));
    lv.setPadding(20, 5, 5, 10);
    lv.setBackgroundColor(0);
    lv.setCacheColorHint(0);
    lv.setItemsCanFocus(true);
    lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(),
            R.layout.server_list_item, new ArrayList<String>());
    lv.setAdapter(serverListAdapter);

    new IPAutoDiscoveryServer() {
        @Override
        protected void onProgressUpdate(Void... values) {
            if (progressLayout != null) {
                progressLayout.setVisibility(View.VISIBLE);
            }
        }

        @Override
        protected void onPostExecute(List<String> result) {
            int length = result.size();
            for (int i = 0; i < length; i++) {
                serverListAdapter.add(result.get(i));
            }
            if (length > 0) {
                lv.setItemChecked(0, true);
                currentServer = serverListAdapter.getItem(0);
                AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer);
            }
            if (progressLayout != null) {
                progressLayout.setVisibility(View.INVISIBLE);
            }
            requestPanelList();
            checkAuthentication();
            requestAccess();
        }
    }.execute((Void) null);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            currentServer = (String) parent.getItemAtPosition(position);
            AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer);
            requestPanelList();
            checkAuthentication();
            requestAccess();
        }
    });

    return lv;
}

From source file:com.example.maciej.mytask.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);

    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);/*from www.j  a  va2  s  .c o  m*/

    createNotification();

    mDateTimeTextView = (TextView) findViewById(R.id.dateTimeTextView);
    //      final Button addTaskBtn = (Button) findViewById(R.id.addTaskBtn);
    final ListView listview = (ListView) findViewById(R.id.taskListview);
    //      final CheckedTextView listitem = (CheckedTextView) findViewById(R.id.checkedTextView1);
    mNameList = new ArrayList<String>();
    mDescriptionList = new ArrayList<String>();
    mDateList = new ArrayList<String>();

    String savedNameList = getSharedPreferences(PREFS_TASKS, MODE_PRIVATE).getString(KEY_NAME_LIST, null);
    if (savedNameList != null) {
        String[] name_items = savedNameList.split(",");
        mNameList = new ArrayList<String>(Arrays.asList(name_items));
    }

    String savedDescriptionList = getSharedPreferences(PREFS_TASKS, MODE_PRIVATE)
            .getString(KEY_DESCRIPTION_LIST, null);
    if (savedDescriptionList != null) {
        String[] description_items = savedDescriptionList.split(",");
        mDescriptionList = new ArrayList<String>(Arrays.asList(description_items));
    }

    String savedDateList = getSharedPreferences(PREFS_TASKS, MODE_PRIVATE).getString(KEY_DATE_LIST, null);
    if (savedDateList != null) {
        String[] date_items = savedDateList.split(",");
        mDateList = new ArrayList<String>(Arrays.asList(date_items));
    }

    mAdapter = new ArrayAdapter<String>(this, R.layout.list_item, mNameList);
    listview.setAdapter(mAdapter);
    listview.setItemsCanFocus(false);
    listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            CheckedTextView item = (CheckedTextView) view;
            if (item.isChecked()) {
                Toast.makeText(getApplicationContext(), getString(R.string.checked), Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(getApplicationContext(), getString(R.string.unchecked), Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            descriptionClicked(view);
            return true;
        }
    });

    mTickReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
                mDateTimeTextView.setText(getCurrentTimeStamp());
            }
        }
    };

}

From source file:com.fsck.k9.activity.Accounts.java

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);

    if (!K9.isHideSpecialAccounts()) {
        createSpecialAccounts();//w w  w. j ava  2 s  .  c o  m
    }

    Account[] accounts = Preferences.getPreferences(this).getAccounts();
    Intent intent = getIntent();
    //onNewIntent(intent);

    // see if we should show the welcome message
    if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) {
        onImport();
    } else if (accounts.length < 1) {
        WelcomeMessage.showWelcomeMessage(this);
        finish();
        return;
    }

    if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) {
        finish();
        return;
    }

    boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
    if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) {
        onOpenAccount(mUnifiedInboxAccount);
        finish();
        return;
    } else if (startup && accounts.length == 1 && onOpenAccount(accounts[0])) {
        finish();
        return;
    }

    mActionBar = getSupportActionBar();
    initializeActionBar();
    //setContentView(R.layout.accounts);
    ListView listView = getListView();
    listView.setOnItemClickListener(this);
    listView.setItemsCanFocus(false);
    listView.setScrollingCacheEnabled(false);
    registerForContextMenu(listView);

    if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) {
        String accountUuid = icicle.getString("selectedContextAccount");
        mSelectedContextAccount = Preferences.getPreferences(this).getAccount(accountUuid);
    }

    restoreAccountStats(icicle);
    mHandler.setViewTitle();

    // Handle activity restarts because of a configuration change (e.g. rotating the screen)
    mNonConfigurationInstance = (NonConfigurationInstance) getLastCustomNonConfigurationInstance();
    if (mNonConfigurationInstance != null) {
        mNonConfigurationInstance.restore(this);
    }

    ChangeLog cl = new ChangeLog(this);
    if (cl.isFirstRun()) {
        cl.getLogDialog().show();
    }
}