Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final Account[] accounts = AccountManager.get(ctx).getAccountsByType("com.google");// Get an instance and retrieve all google accounts.
- final List<String> accountNames = new ArrayList<String>();
- for (Account account : accounts)
- accountNames.add(account.name);
- ListView accountList = (ListView) findViewById(R.id.st_account_list);// st_account_list is defined in an XML layout
- accountList.setAdapter(new ArrayAdapter<String>(ctx, android.R.layout.simple_list_item_1, accountNames));
- accountList.setOnItemClickListener(new OnItemClickListener()
- {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int pos, long id)
- {
- checkAccount(accounts[pos]);
- }
- });
Add Comment
Please, Sign In to add comment