List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects)
From source file:com.umeng.message.example.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pushDao = PushDao.getInstance(this); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); screenWidth = dm.widthPixels;//from w ww . j a v a2 s .c om setContentView(R.layout.activity_main); printKeyValue(); mPushAgent = PushAgent.getInstance(this); mPushAgent.onAppStart(); mPushAgent.enable(MyApplication.mRegisterCallback); tvStatus = (TextView) findViewById(R.id.tvStatus); btnEnable = (ImageView) findViewById(R.id.btnEnable); btnaAddTag = (Button) findViewById(R.id.btnAddTags); btnAddAlias = (Button) findViewById(R.id.btnAddAlias); btnListTag = (Button) findViewById(R.id.btnListTags); infoTextView = (TextView) findViewById(R.id.info); edTag = (EditText) findViewById(R.id.edTag); edAlias = (EditText) findViewById(R.id.edAlias); edAliasType = (EditText) findViewById(R.id.edAliasType); spAliasType = (Spinner) findViewById(R.id.spAliasType); edAliasType.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edAliasTypeFocus = true; } else { edAliasTypeFocus = false; } } }); edAliasType.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (edAliasTypeFocus) { spAliasType.setSelection(0); } } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); String[] aliasType = new String[] { "Alias Type:", ALIAS_TYPE.SINA_WEIBO, ALIAS_TYPE.BAIDU, ALIAS_TYPE.KAIXIN, ALIAS_TYPE.QQ, ALIAS_TYPE.RENREN, ALIAS_TYPE.TENCENT_WEIBO, ALIAS_TYPE.WEIXIN }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, aliasType); spAliasType.setAdapter(adapter); spAliasType.setBackgroundColor(Color.LTGRAY); spAliasType.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub TextView tv = (TextView) arg1; if (tv != null) { int rate = (int) (5.0f * (float) screenWidth / 320.0f); int textSize = rate < 15 ? 15 : rate; tv.setTextSize((float) textSize); } if (arg2 != 0) { String type = (String) spAliasType.getItemAtPosition(arg2); edAliasType.setText(type); } else if (!edAliasTypeFocus) { edAliasType.setText(""); } } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); tvStatus.setOnClickListener(clickListener); btnEnable.setOnClickListener(clickListener); btnaAddTag.setOnClickListener(clickListener); btnListTag.setOnClickListener(clickListener); btnAddAlias.setOnClickListener(clickListener); updateStatus(); mPushAgent.setPushIntentServiceClass(MyPushIntentService.class); callbackReceiver = new CallbackReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(MyApplication.CALLBACK_RECEIVER_ACTION); registerReceiver(callbackReceiver, filter); }
From source file:com.gimranov.zandy.app.AttachmentActivity.java
/** Called when the activity is first created. */ @Override// www. j a v a2 s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tmpFiles = new ArrayList<File>(); db = new Database(this); /* Get the incoming data from the calling activity */ final String itemKey = getIntent().getStringExtra("com.gimranov.zandy.app.itemKey"); Item item = Item.load(itemKey, db); this.item = item; if (item == null) { Log.e(TAG, "AttachmentActivity started without itemKey; finishing."); finish(); return; } this.setTitle(getResources().getString(R.string.attachments_for_item, item.getTitle())); ArrayList<Attachment> rows = Attachment.forItem(item, db); /* * We use the standard ArrayAdapter, passing in our data as a Attachment. * Since it's no longer a simple TextView, we need to override getView, but * we can do that anonymously. */ setListAdapter(new ArrayAdapter<Attachment>(this, R.layout.list_attach, rows) { @Override public View getView(int position, View convertView, ViewGroup parent) { View row; // We are reusing views, but we need to initialize it if null if (null == convertView) { LayoutInflater inflater = getLayoutInflater(); row = inflater.inflate(R.layout.list_attach, null); } else { row = convertView; } ImageView tvType = (ImageView) row.findViewById(R.id.attachment_type); TextView tvSummary = (TextView) row.findViewById(R.id.attachment_summary); Attachment att = getItem(position); Log.d(TAG, "Have an attachment: " + att.title + " fn:" + att.filename + " status:" + att.status); tvType.setImageResource(Item.resourceForType(att.getType())); try { Log.d(TAG, att.content.toString(4)); } catch (JSONException e) { Log.e(TAG, "JSON parse exception when reading attachment content", e); } if (att.getType().equals("note")) { String note = att.content.optString("note", ""); if (note.length() > 40) { note = note.substring(0, 40); } tvSummary.setText(note); } else { StringBuffer status = new StringBuffer(getResources().getString(R.string.status)); if (att.status == Attachment.AVAILABLE) status.append(getResources().getString(R.string.attachment_zfs_available)); else if (att.status == Attachment.LOCAL) status.append(getResources().getString(R.string.attachment_zfs_local)); else status.append(getResources().getString(R.string.attachment_unknown)); tvSummary.setText(att.title + " " + status.toString()); } return row; } }); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemLongClickListener(new OnItemLongClickListener() { // Warning here because Eclipse can't tell whether my ArrayAdapter is // being used with the correct parametrization. @SuppressWarnings("unchecked") public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // If we have a click on an entry, show its note ArrayAdapter<Attachment> adapter = (ArrayAdapter<Attachment>) parent.getAdapter(); Attachment row = adapter.getItem(position); if (row.content.has("note")) { Log.d(TAG, "Trying to start note view activity for: " + row.key); Intent i = new Intent(getBaseContext(), NoteActivity.class); i.putExtra("com.gimranov.zandy.app.attKey", row.key);//row.content.optString("note", "")); startActivity(i); } return true; } }); lv.setOnItemClickListener(new OnItemClickListener() { // Warning here because Eclipse can't tell whether my ArrayAdapter is // being used with the correct parametrization. @SuppressWarnings("unchecked") public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // If we have a long click on an entry, do something... ArrayAdapter<Attachment> adapter = (ArrayAdapter<Attachment>) parent.getAdapter(); Attachment row = adapter.getItem(position); String url = (row.url != null && !row.url.equals("")) ? row.url : row.content.optString("url"); if (!row.getType().equals("note")) { Bundle b = new Bundle(); b.putString("title", row.title); b.putString("attachmentKey", row.key); b.putString("content", url); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); int linkMode = row.content.optInt("linkMode", Attachment.MODE_IMPORTED_URL); if (settings.getBoolean("webdav_enabled", false)) b.putString("mode", "webdav"); else b.putString("mode", "zfs"); if (linkMode == Attachment.MODE_IMPORTED_FILE || linkMode == Attachment.MODE_IMPORTED_URL) { loadFileAttachment(b); } else { AttachmentActivity.this.b = b; showDialog(DIALOG_CONFIRM_NAVIGATE); } } if (row.getType().equals("note")) { Bundle b = new Bundle(); b.putString("attachmentKey", row.key); b.putString("itemKey", itemKey); b.putString("content", row.content.optString("note", "")); removeDialog(DIALOG_NOTE); AttachmentActivity.this.b = b; showDialog(DIALOG_NOTE); } return; } }); }
From source file:com.arantius.tivocommander.Explore.java
public void doRecord(View v) { ArrayAdapter<String> choicesAdapter = new ArrayAdapter<String>(this, android.R.layout.select_dialog_item, mChoices);/*from ww w . ja va 2 s .c o m*/ Builder dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle("Operation?"); dialogBuilder.setAdapter(choicesAdapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int position) { setRefreshResult(); String label = mChoices.get(position); if (RecordActions.DONT_RECORD.toString().equals(label)) { getParent().setProgressBarIndeterminateVisibility(true); MindRpc.addRequest(new RecordingUpdate(mRecordingId, "cancelled"), new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { getParent().setProgressBarIndeterminateVisibility(false); ImageView iconSubType = (ImageView) findViewById(R.id.icon_sub_type); TextView textSubType = (TextView) findViewById(R.id.text_sub_type); iconSubType.setVisibility(View.GONE); textSubType.setVisibility(View.GONE); } }); } else if (RecordActions.RECORD.toString().equals(label)) { Intent intent = new Intent(getBaseContext(), SubscribeOffer.class); intent.putExtra("contentId", mContentId); intent.putExtra("offerId", mOfferId); startActivity(intent); } else if (RecordActions.RECORD_STOP.toString().equals(label)) { getParent().setProgressBarIndeterminateVisibility(true); MindRpc.addRequest(new RecordingUpdate(mRecordingId, "complete"), new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { getParent().setProgressBarIndeterminateVisibility(false); mRecordingId = null; } }); } else if (RecordActions.SP_ADD.toString().equals(label)) { Intent intent = new Intent(getBaseContext(), SubscribeCollection.class); intent.putExtra("collectionId", mCollectionId); startActivity(intent); // TODO: Start for result, get subscription ID. } else if (RecordActions.SP_CANCEL.toString().equals(label)) { getParent().setProgressBarIndeterminateVisibility(true); MindRpc.addRequest(new Unsubscribe(mSubscriptionId), new MindRpcResponseListener() { public void onResponse(MindRpcResponse response) { getParent().setProgressBarIndeterminateVisibility(false); mSubscriptionId = null; } }); } else if (RecordActions.SP_MODIFY.toString().equals(label)) { Intent intent = new Intent(getBaseContext(), SubscribeCollection.class); intent.putExtra("collectionId", mCollectionId); intent.putExtra("subscriptionId", mSubscriptionId); intent.putExtra("subscriptionJson", Utils.stringifyToJson(mSubscription)); startActivity(intent); } } }); AlertDialog dialog = dialogBuilder.create(); dialog.show(); }
From source file:com.makerfaireorlando.makerfaireorlando.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Assume true if the key does not yet exist prefs = getSharedPreferences("com.makerfaireorlando.makerfaireorlando", MODE_PRIVATE); mCategories = new ArrayList<String>(); if (savedInstanceState != null) { // Restore last state for checked position. mCurCheckPosition = savedInstanceState.getString("curChoice"); }/*www. ja v a 2s . co m*/ setContentView(R.layout.activity_main); mTitle = mDrawerTitle = getTitle(); titles = getResources().getStringArray(R.array.selection_array); classes = getResources().getStringArray(R.array.nav_classes); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, titles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action ClickListenerto toggle nav drawer getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_navigation_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } //getSupportFragmentManager().findFragmentByTag(mCurCheckPosition).setMenuVisibility(true); } public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(mDrawerTitle); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } //getSupportFragmentManager().findFragmentByTag(mCurCheckPosition).setMenuVisibility(false); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { FragmentTransaction tx = getSupportFragmentManager().beginTransaction().addToBackStack(null); tx.replace(R.id.content_frame, Fragment.instantiate(MainActivity.this, classes[0]), classes[0]); tx.commit(); mCurCheckPosition = classes[0]; mDrawerList.setItemChecked(0, true); } if (context == null) { context = getApplicationContext(); } if (checkPlayServices()) { Log.i(TAG, "This device supports Google Play Services."); gcm = GoogleCloudMessaging.getInstance(this); regid = getRegistrationId(context); if (regid.isEmpty()) { registerInBackground(); } } else { Log.i(TAG, "No valid Google Play Services APK found."); } }
From source file:org.yaoha.YaohaActivity.java
/** Called when the activity is first created. */ @Override//from www . java2 s.c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); if (staticApplicationContext == null) staticApplicationContext = getApplicationContext(); this.prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); text_fav_1 = new TextView(this); text_fav_1.setText(R.string.add_favorite); text_fav_2 = new TextView(this); text_fav_2.setText(R.string.add_favorite); text_fav_3 = new TextView(this); text_fav_3.setText(R.string.add_favorite); text_fav_4 = new TextView(this); text_fav_4.setText(R.string.add_favorite); text_fav_5 = new TextView(this); text_fav_5.setText(R.string.add_favorite); text_fav_6 = new TextView(this); text_fav_6.setText(R.string.add_favorite); startButton = (Button) findViewById(R.id.button_start); startButton.setOnClickListener(this); button_favorite_1 = (ImageButton) findViewById(R.id.button_fav_1); button_favorite_1.setOnClickListener(this); // button_favorite_1.setScaleType(F) button_favorite_2 = (ImageButton) findViewById(R.id.button_fav_2); button_favorite_2.setOnClickListener(this); button_favorite_3 = (ImageButton) findViewById(R.id.button_fav_3); button_favorite_3.setOnClickListener(this); button_favorite_4 = (ImageButton) findViewById(R.id.button_fav_4); button_favorite_4.setOnClickListener(this); button_favorite_5 = (ImageButton) findViewById(R.id.button_fav_5); button_favorite_5.setOnClickListener(this); button_favorite_6 = (ImageButton) findViewById(R.id.button_fav_6); button_favorite_6.setOnClickListener(this); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, SHOP_TYPES); MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.searchTextfield); textView.setAdapter(adapter); textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); registerForContextMenu(button_favorite_1); registerForContextMenu(button_favorite_2); registerForContextMenu(button_favorite_3); registerForContextMenu(button_favorite_4); registerForContextMenu(button_favorite_5); registerForContextMenu(button_favorite_6); // SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(getBaseContext()); if (prefs.getBoolean("start_with_map", false) == true) { startButton.performClick(); } OsmNodeDbHelper.create(getApplicationContext()); getFavSettings(); }
From source file:com.hybris.mobile.app.commerce.fragment.AddressDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_address_dialog, container, false); if (mNestedFragment) { view.findViewById(R.id.address_dialog_footer).setVisibility(View.GONE); view.setPadding(0, 0, 0, 0);//from w w w . ja v a2s . co m } mAddressUserTitleSpinner = (Spinner) view.findViewById(R.id.address_user_title_spinner); mAddressSaveButton = (Button) view.findViewById(R.id.address_save_button); mAddressFirstNameEditText = (EditText) view.findViewById(R.id.address_firstname_edittext); mAddressLastNameEditText = (EditText) view.findViewById(R.id.address_lastname_edittext); mAddressCountrySpinner = (Spinner) view.findViewById(R.id.address_country_spinner); mAddressLine1Edittext = (EditText) view.findViewById(R.id.address_line1_edittext); mAddressLine2Edittext = (EditText) view.findViewById(R.id.address_line2_edittext); mAddressCityEdittext = (EditText) view.findViewById(R.id.address_city_edittext); mAddressPostalCodeEdittext = (EditText) view.findViewById(R.id.address_postal_code_edittext); mAddressStateEdittext = (EditText) view.findViewById(R.id.address_state_edittext); mAddressTitle = (TextView) view.findViewById(R.id.address_title); mTitleAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>()); mCountryAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, new ArrayList<String>()); if (mAddress != null) { if (!mNestedFragment) { mAddressTitle.setText(R.string.address_book_title_edit); //getDialog().setTitle(R.string.address_book_title_edit); } mAddressFirstNameEditText.setText(mAddress.getFirstName()); mAddressLastNameEditText.setText(mAddress.getLastName()); mAddressLine1Edittext.setText(mAddress.getLine1()); mAddressLine2Edittext.setText(mAddress.getLine2()); mAddressCityEdittext.setText(mAddress.getTown()); mAddressPostalCodeEdittext.setText(mAddress.getPostalCode()); if (mAddress.getRegion() != null) { mAddressStateEdittext.setText(mAddress.getRegion().getIsocode()); } mAddressSaveButton.setOnClickListener(mSaveAddressOnClickListener); populateTitle(); populateCountry(); } else { if (!mNestedFragment) { mAddressTitle.setText(R.string.address_book_title_new); // getDialog().setTitle(R.string.address_book_title_new); } mAddress = new Address(); mAddressSaveButton.setText(getActivity().getString(R.string.address_dialog_done)); mAddressSaveButton.setOnClickListener(mAddAddressOnClickListener); populateTitle(); populateCountry(); } mAddressUserTitleSpinner.setOnItemSelectedListener(mAddressDialogSpinnerListener); mAddressCountrySpinner.setOnItemSelectedListener(mAddressDialogSpinnerListener); return view; }
From source file:com.nest5.businessClient.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//*from w ww. j av a 2 s. com*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } // internetConnectionStatus = (ImageView) findViewById(R.id.header_connection_status); SharedPreferences prefs = Util.getSharedPreferences(mContext); if (!isNetworkAvailable()) { internetConnectionStatus.setImageResource(R.drawable.error); prefs.edit().putInt(Util.INTERNET_CONNECTION, Util.INTERNET_DISCONNECTED).commit(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage( "No tienes una conexin a internet activa. Habiltala haciendo click en aceptar y seleccionando luego una red.") .setCancelable(false).setPositiveButton("Aceptar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivityForResult(intent, 1); } }).setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }).show(); } else { prefs.edit().putInt(Util.INTERNET_CONNECTION, Util.INTERNET_CONNECTED).commit(); } }
From source file:falcofinder.android.fuehrerschein.chat.AccountsActivity.java
/** * Sets up the 'connect' screen content. *///from ww w. ja v a2 s.c o m private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); /* * rimuovo aggiunta account perche' disponible da versione 2.2 * ma voglio compatibilita' con 2.1 builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); */ builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Set "connecting" status SharedPreferences prefs = Util.getSharedPreferences(mContext); prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit(); // Get account name mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); // Register register((String) account.getText()); finish(); } }); } }
From source file:com.listomate.activities.AccountsActivity.java
/** * Sets up the 'connect' screen content. *//*from w w w. j av a 2s. c o m*/ private void setConnectScreenContent() { List<String> accounts = getGoogleAccounts(); if (accounts.size() == 0) { // Show a dialog and invoke the "Add Account" activity if requested AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setMessage(R.string.needs_account); builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT)); } }); builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); builder.setIcon(android.R.drawable.stat_sys_warning); builder.setTitle(R.string.attention); builder.show(); } else { final ListView listView = (ListView) findViewById(R.id.select_account); listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts)); listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); listView.setItemChecked(mAccountSelectedPosition, true); final Button connectButton = (Button) findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Register in the background and terminate the activity mAccountSelectedPosition = listView.getCheckedItemPosition(); TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition); register((String) account.getText()); finish(); } }); final Button exitButton = (Button) findViewById(R.id.exit); exitButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { finish(); } }); } }
From source file:com.bringcommunications.etherpay.SendActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overlay_frame_layout = new FrameLayout(getApplicationContext()); setContentView(overlay_frame_layout); ///* ww w . j a v a 2 s . c o m*/ context = this; hex = new Hex(); preferences = getSharedPreferences("etherpay.bringcommunications.com", MODE_PRIVATE); private_key = preferences.getString("key", private_key); acct_addr = preferences.getString("acct_addr", acct_addr); long wei_balance = preferences.getLong("balance", 0); eth_balance = (float) wei_balance / Util.WEI_PER_ETH; price = preferences.getFloat("price", price); show_gas = preferences.getBoolean("show_gas", show_gas); show_data = preferences.getBoolean("show_data", show_data); boolean denomination_eth = preferences.getBoolean("denomination_eth", true); System.out.println("denomination_eth is " + denomination_eth); denomination = denomination_eth ? Denomination.ETH : Denomination.FINNEY; auto_pay = getIntent().getStringExtra("AUTO_PAY"); to_addr = getIntent().getStringExtra("TO_ADDR"); String size_str = getIntent().getStringExtra("SIZE"); eth_size = Float.valueOf(size_str); data = getIntent().getStringExtra("DATA"); send_is_done = false; // View activity_send_view = getLayoutInflater().inflate(R.layout.activity_send, overlay_frame_layout, false); setContentView(activity_send_view); // Spinner dropdown = (Spinner) findViewById(R.id.denomination); String[] items = new String[] { "ETH", "Finney" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items); dropdown.setSelection((denomination == Denomination.ETH) ? 0 : 1); dropdown.setOnItemSelectedListener(this); dropdown.setAdapter(adapter); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); String app_name = getResources().getString(R.string.app_name); toolbar.setTitle(app_name); toolbar.setSubtitle("Send Payment"); toolbar.setBackgroundResource(R.color.color_toolbar); setSupportActionBar(toolbar); // TextView to_addr_view = (TextView) findViewById(R.id.to_addr); to_addr_view.setText(to_addr); // TextView size_view = (TextView) findViewById(R.id.size); size_str = (denomination == Denomination.ETH) ? String.format("%1.03f", eth_size) : String.format("%03d", (int) (eth_size * 1000 + 0.5)); size_view.setText(size_str); // LinearLayout gas_layout = (LinearLayout) findViewById(R.id.gas_layout); TextView gas_prompt_view = (TextView) findViewById(R.id.gas_prompt); TextView gas_view = (TextView) findViewById(R.id.gas); ImageButton gas_help_view = (ImageButton) findViewById(R.id.gas_help); if (show_gas) { String gas_str = String.format("%7d", gas_limit); gas_view.setText(gas_str); gas_layout.setVisibility(View.VISIBLE); gas_prompt_view.setVisibility(View.VISIBLE); gas_help_view.setVisibility(View.VISIBLE); gas_view.setVisibility(View.VISIBLE); } else { gas_layout.setVisibility(View.GONE); gas_prompt_view.setVisibility(View.GONE); gas_help_view.setVisibility(View.GONE); gas_view.setVisibility(View.GONE); } LinearLayout data_layout = (LinearLayout) findViewById(R.id.data_layout); TextView data_prompt_view = (TextView) findViewById(R.id.data_prompt); TextView data_view = (TextView) findViewById(R.id.data); ImageButton data_help_view = (ImageButton) findViewById(R.id.data_help); if (show_data) { data_view.setText(data); data_layout.setVisibility(View.VISIBLE); data_prompt_view.setVisibility(View.VISIBLE); data_help_view.setVisibility(View.VISIBLE); data_view.setVisibility(View.VISIBLE); } else { data = ""; data_layout.setVisibility(View.GONE); data_prompt_view.setVisibility(View.GONE); data_help_view.setVisibility(View.GONE); data_view.setVisibility(View.GONE); } // //sanity check if (to_addr.length() != 42) { this.finish(); } }