Guest User

Untitled

a guest
Jan 21st, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. final Account[] accounts = AccountManager.get(ctx).getAccountsByType("com.google");// Get an instance and retrieve all google accounts.
  2. final List<String> accountNames = new ArrayList<String>();
  3. for (Account account : accounts)
  4. accountNames.add(account.name);
  5. ListView accountList = (ListView) findViewById(R.id.st_account_list);// st_account_list is defined in an XML layout
  6. accountList.setAdapter(new ArrayAdapter<String>(ctx, android.R.layout.simple_list_item_1, accountNames));
  7. accountList.setOnItemClickListener(new OnItemClickListener()
  8. {
  9. @Override
  10. public void onItemClick(AdapterView<?> parent, View view, int pos, long id)
  11. {
  12. checkAccount(accounts[pos]);
  13. }
  14. });
Add Comment
Please, Sign In to add comment