List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:com.moonpi.tapunlock.MainActivity.java
@Override protected Dialog onCreateDialog(int id) { // Scan NFC Tag dialog, inflate image LayoutInflater factory = LayoutInflater.from(MainActivity.this); final View view = factory.inflate(R.layout.scan_tag_image, null); // Ask for tagTitle (tagName) in dialog final EditText tagTitle = new EditText(this); tagTitle.setHint(getResources().getString(R.string.set_tag_name_dialog_hint)); tagTitle.setSingleLine(true);//from w ww. jav a2 s .c o m tagTitle.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); // Set tagTitle maxLength int maxLength = 50; InputFilter[] array = new InputFilter[1]; array[0] = new InputFilter.LengthFilter(maxLength); tagTitle.setFilters(array); final LinearLayout l = new LinearLayout(this); l.setOrientation(LinearLayout.VERTICAL); l.addView(tagTitle); // Dialog that shows scan tag image if (id == DIALOG_READ) { return new AlertDialog.Builder(this).setTitle(R.string.scan_tag_dialog_title).setView(view) .setCancelable(false) .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialogCancelled = true; killForegroundDispatch(); dialog.cancel(); } }).create(); } // Dialog that asks for tagName and stores it after 'Ok' pressed else if (id == DIALOG_SET_TAGNAME) { tagTitle.requestFocus(); return new AlertDialog.Builder(this).setTitle(R.string.set_tag_name_dialog_title).setView(l) .setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { JSONObject newTag = new JSONObject(); try { newTag.put("tagName", tagTitle.getText()); newTag.put("tagID", tagID); } catch (JSONException e) { e.printStackTrace(); } tags.put(newTag); writeToJSON(); adapter.notifyDataSetChanged(); updateListViewHeight(listView); if (tags.length() == 0) noTags.setVisibility(View.VISIBLE); else noTags.setVisibility(View.INVISIBLE); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_tag_added, Toast.LENGTH_SHORT); toast.show(); imm.hideSoftInputFromWindow(tagTitle.getWindowToken(), 0); tagID = ""; tagTitle.setText(""); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tagID = ""; tagTitle.setText(""); imm.hideSoftInputFromWindow(tagTitle.getWindowToken(), 0); dialog.cancel(); } }).create(); } return null; }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.item1: ////from w w w . java 2 s . c o m // //mViewPager.setCurrentItem((new PageProvider().getPageCount()-1)); // 1. Instantiate an AlertDialog.Builder with its constructor String[] pages = new String[850]; for (int i = 0; i < 850; i++) { pages[i] = i + 1 + ""; } AlertDialog.Builder builder = new AlertDialog.Builder(ViewPagerActivity.this); // 2. Chain together various setter methods to set the dialog characteristics builder.setTitle("Go To Page").setItems(pages, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mViewPager.setCurrentItem(849 - which); // The 'which' argument contains the index position // of the selected item } }); // 3. Get the AlertDialog from create() AlertDialog dialog = builder.create(); dialog.show(); return true; case R.id.item2: // // //mViewPager.setCurrentItem((new PageProvider().getPageCount()-1)); // 1. Instantiate an AlertDialog.Builder with its constructor AlertDialog.Builder builder2 = new AlertDialog.Builder(ViewPagerActivity.this); String[] juz = getResources().getStringArray(R.array.juz); // 2. Chain together various setter methods to set the dialog characteristics builder2.setTitle("Go To Juz (Parah)").setItems(juz, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 1); } if (which == 1) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 31); } if (which == 2) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 59); } if (which == 3) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 87); } if (which == 4) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 115); } if (which == 5) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 143); } if (which == 6) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 171); } if (which == 7) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 199); } if (which == 8) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 227); } if (which == 9) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 255); } if (which == 10) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 283); } if (which == 11) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 311); } if (which == 12) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 339); } if (which == 13) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 367); } if (which == 14) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 395); } if (which == 15) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 423); } if (which == 16) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 451); } if (which == 17) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 479); } if (which == 18) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 507); } if (which == 19) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 535); } if (which == 20) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 561); } if (which == 21) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 589); } if (which == 22) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 615); } if (which == 23) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 643); } if (which == 24) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 669); } if (which == 25) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 699); } if (which == 26) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 729); } if (which == 27) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 759); } if (which == 28) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 789); } if (which == 29) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 821); } // The 'which' argument contains the index position // of the selected item } }); // 3. Get the AlertDialog from create() AlertDialog dialog2 = builder2.create(); dialog2.show(); return true; case R.id.item3: // // //mViewPager.setCurrentItem((new PageProvider().getPageCount()-1)); // 1. Instantiate an AlertDialog.Builder with its constructor AlertDialog.Builder builder3 = new AlertDialog.Builder(ViewPagerActivity.this); String[] surah = getResources().getStringArray(R.array.surah); // 2. Chain together various setter methods to set the dialog characteristics builder3.setTitle("Go To Surah").setItems(surah, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { dialog.dismiss(); mViewPager.setCurrentItem(620 - 4); } if (which == 1) { dialog.dismiss(); mViewPager.setCurrentItem(620 - 5); } if (which == 2) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 70); } if (which == 3) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 108); } if (which == 4) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 149); } if (which == 5) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 179); } if (which == 6) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 211); } if (which == 7) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 247); } if (which == 8) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 262); } if (which == 9) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 290); } if (which == 10) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 310); } if (which == 11) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 330); } if (which == 12) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 348); } if (which == 13) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 357); } if (which == 14) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 366); } if (which == 15) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 374); } if (which == 16) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 390); } if (which == 17) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 410); } if (which == 18) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 427); } if (which == 19) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 437); } if (which == 20) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 451); } if (which == 21) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 464); } if (which == 22) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 479); } if (which == 23) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 489); } if (which == 24) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 503); } if (which == 25) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 513); } if (which == 26) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 527); } if (which == 27) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 539); } if (which == 28) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 554); } if (which == 29) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 564); } if (which == 30) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 573); } if (which == 31) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 579); } if (which == 32) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 583); } if (which == 33) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 597); } if (which == 34) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 605); } if (which == 35) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 613); } if (which == 36) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 620); } if (which == 37) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 630); } if (which == 38) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 637); } if (which == 39) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 649); } if (which == 40) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 661); } if (which == 41) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 670); } if (which == 42) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 679); } if (which == 43) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 688); } if (which == 44) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 693); } if (which == 45) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 699); } if (which == 46) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 706); } if (which == 47) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 712); } if (which == 48) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 718); } if (which == 49) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 723); } if (which == 50) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 728); } if (which == 51) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 731); } if (which == 52) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 734); } if (which == 53) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 738); } if (which == 54) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 742); } if (which == 55) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 747); } if (which == 56) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 752); } if (which == 57) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 759); } if (which == 58) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 763); } if (which == 59) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 768); } if (which == 60) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 772); } if (which == 61) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 775); } if (which == 62) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 777); } if (which == 63) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 779); } if (which == 64) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 782); } if (which == 65) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 785); } if (which == 66) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 789); } if (which == 67) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 792); } if (which == 68) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 796); } if (which == 69) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 799); } if (which == 70) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 802); } if (which == 71) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 805); } if (which == 72) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 808); } if (which == 73) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 810); } if (which == 74) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 813); } if (which == 75) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 815); } if (which == 76) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 818); } if (which == 77) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 821); } if (which == 78) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 822); } if (which == 79) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 824); } if (which == 80) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 826); } if (which == 81) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 827); } if (which == 82) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 828); } if (which == 83) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 830); } if (which == 84) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 831); } if (which == 85) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 832); } if (which == 86) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 833); } if (which == 87) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 834); } if (which == 88) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 835); } if (which == 89) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 837); } if (which == 90) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 838); } if (which == 91) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 839); } if (which == 92) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 840); } if (which == 93) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 840); } if (which == 94) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 841); } if (which == 95) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 841); } if (which == 96) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 842); } if (which == 97) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 842); } if (which == 98) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 843); } if (which == 99) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 844); } if (which == 100) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 845); } if (which == 101) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 845); } if (which == 102) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 846); } if (which == 103) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 846); } if (which == 104) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 846); } if (which == 105) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 847); } if (which == 106) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 847); } if (which == 107) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 848); } if (which == 108) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 848); } if (which == 109) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 848); } if (which == 110) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 849); } if (which == 111) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 849); } if (which == 112) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 849); } if (which == 113) { dialog.dismiss(); mViewPager.setCurrentItem(850 - 850); } // The 'which' argument contains the index position // of the selected item } }); // 3. Get the AlertDialog from create() AlertDialog dialog3 = builder3.create(); dialog3.show(); return true; case R.id.item4: Builder builderr = new Builder(this); Date cDate = new Date(); final String fDate = new SimpleDateFormat("MM/dd/yy").format(cDate); Date dt = new Date(); int hours = dt.getHours(); int minutes = dt.getMinutes(); SimpleDateFormat sdf = new SimpleDateFormat("hh:mmaa"); String time1 = sdf.format(dt); final EditText input = new EditText(this); InputFilter[] FilterArray = new InputFilter[1]; FilterArray[0] = new InputFilter.LengthFilter(18); input.setFilters(FilterArray); input.setText(fDate + " " + time1.toLowerCase()); builderr.setTitle("Bookmark").setMessage("Name your Bookmark").setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (!input.getText().toString().equals("")) saveState(input.getText().toString()); else saveState(fDate); setResult(RESULT_OK); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); builderr.show(); return true; case R.id.item5: Intent i = new Intent(ViewPagerActivity.this, Notepadv3.class); startActivity(i); return true; case R.id.item6: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Qazi+Musab"))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/developer?id=Qazi+Musab"))); } return true; case R.id.item7: String appName2 = "com.qaziconsultancy.13linequran"; try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName2))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appName2))); } return true; case R.id.item8: mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1); return true; case R.id.item9: mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1); return true; case R.id.item10: String[] items = new String[9]; items[0] = "$1"; items[1] = "$2"; items[2] = "$3"; items[3] = "$4"; items[4] = "$5"; items[5] = "$10"; items[6] = "$20"; items[7] = "$50"; items[8] = "$100"; AlertDialog.Builder chooser = new AlertDialog.Builder(ViewPagerActivity.this); chooser.setTitle("Contribute").setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: contributeOneDollar(); break; case 1: contributetwoDollars(); break; case 2: contributeThreeDollars(); break; case 3: contributeFourDollars(); break; case 4: contributeFiveDollars(); break; case 5: contributeTenDollars(); break; case 6: contributeTwentyDollars(); break; case 7: contributeFiftyDollars(); break; case 8: contributeHundredDollars(); break; } } }); // 3. Get the AlertDialog from create() AlertDialog myChooser = chooser.create(); myChooser.show(); return true; default: return true; } }
From source file:com.thousandthoughts.tutorials.SensorFusionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w ww.j a v a 2 s. c o m layout = (RelativeLayout) findViewById(R.id.mainlayout); IP1 = ""; IP2 = ""; angle1 = 0.0f; angle2 = 0.0f; gyroOrientation[0] = 0.0f; gyroOrientation[1] = 0.0f; gyroOrientation[2] = 0.0f; // initialise gyroMatrix with identity matrix gyroMatrix[0] = 1.0f; gyroMatrix[1] = 0.0f; gyroMatrix[2] = 0.0f; gyroMatrix[3] = 0.0f; gyroMatrix[4] = 1.0f; gyroMatrix[5] = 0.0f; gyroMatrix[6] = 0.0f; gyroMatrix[7] = 0.0f; gyroMatrix[8] = 1.0f; // get sensorManager and initialise sensor listeners mSensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); initListeners(); // wait for one second until gyroscope and magnetometer/accelerometer // data is initialised then scedule the complementary filter task fuseTimer.scheduleAtFixedRate(new calculateFusedOrientationTask(), 1000, TIME_CONSTANT); // GUI stuff try { client1 = new MyCoapClient(this.IP1); client2 = new MyCoapClient(this.IP2); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } json = new JSONObject(); mHandler = new Handler(); radioSelection = 0; d.setRoundingMode(RoundingMode.HALF_UP); d.setMaximumFractionDigits(3); d.setMinimumFractionDigits(3); /// Application layout here only RelativeLayout.LayoutParams left = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams right = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams up = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams down = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams button1 = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams button2 = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams text1 = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams text2 = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); ImageView img_left = new ImageView(this); ImageView img_right = new ImageView(this); ImageView img_up = new ImageView(this); ImageView img_down = new ImageView(this); ImageView img_button1 = new ImageView(this); ImageView img_button2 = new ImageView(this); final EditText edittext1 = new EditText(this); final EditText edittext2 = new EditText(this); img_left.setImageResource(R.drawable.left_button); img_right.setImageResource(R.drawable.right_button); img_up.setImageResource(R.drawable.up); img_down.setImageResource(R.drawable.down); img_button1.setImageResource(R.drawable.button); img_button2.setImageResource(R.drawable.button); left.setMargins(0, 66, 0, 0); right.setMargins(360, 66, 0, 0); up.setMargins(240, 90, 0, 0); down.setMargins(240, 240, 0, 0); button1.setMargins(440, 800, 0, 0); button2.setMargins(440, 900, 0, 0); text1.setMargins(5, 800, 0, 0); text2.setMargins(5, 900, 0, 0); layout.addView(img_left, left); layout.addView(img_right, right); layout.addView(img_up, up); layout.addView(img_down, down); layout.addView(img_button1, button1); layout.addView(edittext1, text1); layout.addView(img_button2, button2); layout.addView(edittext2, text2); img_left.getLayoutParams().height = 560; img_left.getLayoutParams().width = 280; img_right.getLayoutParams().height = 560; img_right.getLayoutParams().width = 280; img_up.getLayoutParams().height = 150; img_up.getLayoutParams().width = 150; img_down.getLayoutParams().height = 150; img_down.getLayoutParams().width = 150; img_button1.getLayoutParams().height = 100; img_button1.getLayoutParams().width = 200; edittext1.getLayoutParams().width = 400; edittext1.setText("84.248.76.84"); edittext2.setText("84.248.76.84"); img_button2.getLayoutParams().height = 100; img_button2.getLayoutParams().width = 200; edittext2.getLayoutParams().width = 400; /////////// Define and Remember Position for EACH PHYSICAL OBJECTS (LAPTOPS) ///////////////////// img_button1.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // POSITION OF LAPTOP 1 IS REMEMBERED angle1 = fusedOrientation[0]; IP1 = edittext1.getText().toString(); try { // CREATE CLIENT CONNECT TO FIRST LAPTOP client1 = new MyCoapClient(IP1); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: //view.setImageResource(R.drawable.left_button); break; } return true; } }); img_button2.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // POSITION OF LAPTOP 2 IS REMEMBERED angle2 = fusedOrientation[0]; IP2 = edittext2.getText().toString(); try { // CREATE CLIENT CONNECT TO SECOND LAPTOP client2 = new MyCoapClient(IP2); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: break; } return true; } }); img_left.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: view.setImageResource(R.drawable.left_button_press); ///////////////////// PERFORM CLICK ACTION BASED ON POSITION OF 2 PHYSICAL OBJECTS (LAPTOPs) HERE///////////////////////// // PHONE's ANGLE WITHIN FIRST LAPTOP// if (angle1 != 0.0f) { if (angle1 * 180 / Math.PI - 40.0 < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle1 * 180 / Math.PI + 40.0) { client1.runClient("left pressed"); } } //PHONE's ANGLE WITHIN SECOND LAPTOP// if (angle2 != 0.0f) { if (angle2 * 180 / Math.PI - 40.0 < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle2 * 180 / Math.PI + 40.0) { client2.runClient("left pressed"); } } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: view.setImageResource(R.drawable.left_button); // PHONE's ANGLE WITHIN FIRST LAPTOP// if (angle1 != 0.0f) { if (angle1 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle1 * 180 / Math.PI + 40.0f) { client1.runClient("left released"); } } //PHONE's ANGLE WITHIN SECOND LAPTOP// if (angle2 != 0.0f) { if (angle2 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle2 * 180 / Math.PI + 40.0f) { client2.runClient("left released"); } } break; } return true; } }); img_right.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: view.setImageResource(R.drawable.right_button_press); // PHONE's ANGLE WITHIN FIRST LAPTOP// if (angle1 != 0.0f) { if (angle1 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle1 * 180 / Math.PI + 40.0f) { client1.runClient("right pressed"); } } //PHONE's ANGLE WITHIN SECOND LAPTOP// if (angle2 != 0.0f) { if (angle2 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle2 * 180 / Math.PI + 40.0f) { client2.runClient("right pressed"); } } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: view.setImageResource(R.drawable.right_button); break; } return true; } }); img_up.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: view.setImageResource(R.drawable.up_press); // PHONE's ANGLE WITHIN FIRST LAPTOP// if (angle1 != 0.0f) { if (angle1 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle1 * 180 / Math.PI + 40.0f) { client1.runClient("up pressed"); } } //PHONE's ANGLE WITHIN SECOND LAPTOP// if (angle2 != 0.0f) { if (angle2 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle2 * 180 / Math.PI + 40.0f) { client2.runClient("up pressed"); } } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: view.setImageResource(R.drawable.up); break; } return true; } }); img_down.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: view.setImageResource(R.drawable.down_press); // PHONE's ANGLE WITHIN FIRST LAPTOP// if (angle1 != 0.0f) { if (angle1 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle1 * 180 / Math.PI + 40.0f) { client1.runClient("down pressed"); } } //PHONE's ANGLE WITHIN SECOND LAPTOP// if (angle2 != 0.0f) { if (angle2 * 180 / Math.PI - 40.0f < fusedOrientation[0] * 180 / Math.PI && fusedOrientation[0] * 180 / Math.PI < angle2 * 180 / Math.PI + 40.0f) { client2.runClient("down pressed"); } } break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: view.setImageResource(R.drawable.down); break; } return true; } }); }
From source file:dentex.youtube.downloader.DashboardActivity.java
public void editId3Tags(View view) { BugSenseHandler.leaveBreadcrumb("editId3Tags"); if (newClick) { tagArtist = ""; tagAlbum = ""; tagTitle = ""; tagGenre = ""; tagYear = ""; }/* w w w . jav a2 s . c om*/ AlertDialog.Builder builder = new AlertDialog.Builder(boxThemeContextWrapper); LayoutInflater inflater0 = getLayoutInflater(); final View id3s = inflater0.inflate(R.layout.dialog_edit_id3, null); final EditText artistEt = (EditText) id3s.findViewById(R.id.id3_et_artist); final EditText titleEt = (EditText) id3s.findViewById(R.id.id3_et_title); final EditText albumEt = (EditText) id3s.findViewById(R.id.id3_et_album); final EditText genreEt = (EditText) id3s.findViewById(R.id.id3_et_genre); final EditText yearEt = (EditText) id3s.findViewById(R.id.id3_et_year); if (tagTitle.isEmpty()) { titleEt.setText(currentItem.getBasename()); } else { titleEt.setText(tagTitle); } if (tagYear.isEmpty()) { Calendar cal = new GregorianCalendar(); int y = cal.get(Calendar.YEAR); yearEt.setText(String.valueOf(y)); } else { yearEt.setText(tagYear); } artistEt.setText(tagArtist); albumEt.setText(tagAlbum); genreEt.setText(tagGenre); builder.setView(id3s).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { tagArtist = artistEt.getText().toString(); tagAlbum = albumEt.getText().toString(); tagTitle = titleEt.getText().toString(); tagGenre = genreEt.getText().toString(); tagYear = yearEt.getText().toString(); } }).setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // cancel } }); secureShowDialog(builder); newClick = false; }
From source file:terse.a1.TerseActivity.java
private void viewPath9display(String path, LayoutParams widgetParams) { String explain;//from w w w. j ava 2 s . c om if (terp_error != null) { explain = "terp_error = " + terp_error; } else { try { terp.say("Sending to terp: %s", path); final Dict d = terp.handleUrl(path, taQuery); explain = "DEFAULT EXPLANATION:\n\n" + d.toString(); Str TYPE = d.cls.terp.newStr("type"); Str VALUE = d.cls.terp.newStr("value"); Str TITLE = d.cls.terp.newStr("title"); Str type = (Str) d.dict.get(TYPE); Ur value = d.dict.get(VALUE); Ur title = d.dict.get(TITLE); // { // double ticks = Static.floatAt(d, "ticks", -1); // double nanos = Static.floatAt(d, "nanos", -1); // Toast.makeText( // getApplicationContext(), // Static.fmt("%d ticks, %.3f secs", (long) ticks, // (double) nanos / 1e9), Toast.LENGTH_SHORT) // .show(); // } if (type.str.equals("list") && value instanceof Vec) { final ArrayList<Ur> v = ((Vec) value).vec; final ArrayList<String> labels = new ArrayList<String>(); final ArrayList<String> links = new ArrayList<String>(); for (int i = 0; i < v.size(); i++) { Ur item = v.get(i); String label = item instanceof Str ? ((Str) item).str : item.toString(); if (item instanceof Vec && ((Vec) item).vec.size() == 2) { // OLD STYLE label = ((Vec) item).vec.get(0).toString(); Matcher m = LINK_P.matcher(label); if (m.lookingAt()) { label = m.group(2) + " " + m.group(3); } label += " [" + ((Vec) item).vec.get(1).toString().length() + "]"; links.add(null); // Use old style, not links. } else { // NEW STYLE label = item.toString(); if (label.charAt(0) == '/') { String link = Terp.WHITE_PLUS.split(label, 2)[0]; links.add(link); } else { links.add(""); } } labels.add(label); } if (labels.size() != links.size()) terp.toss("lables#%d links#%d", labels.size(), links.size()); ListView listv = new ListView(this); listv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, labels)); listv.setLayoutParams(widgetParams); listv.setTextFilterEnabled(true); listv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), // Toast.LENGTH_SHORT).show(); String toast_text = ((TextView) view).getText().toString(); // if (v.get(position) instanceof Vec) { if (links.get(position) == null) { // OLD STYLE Vec pair = (Vec) v.get(position); if (pair.vec.size() == 2) { if (pair.vec.get(0) instanceof Str) { String[] words = ((Str) pair.vec.get(0)).str.split("\\|"); Log.i("TT-WORDS", terp.arrayToString(words)); toast_text += "\n\n" + Static.arrayToString(words); if (words[1].equals("link")) { Uri uri = new Uri.Builder().scheme("terse").path(words[2]).build(); Intent intent = new Intent("android.intent.action.MAIN", uri); intent.setClass(getApplicationContext(), TerseActivity.class); startActivity(intent); } } } } else { // NEW STYLE terp.say("NEW STYLE LIST SELECT #%d link=<%s> label=<%s>", position, links.get(position), labels.get(position)); if (links.get(position).length() > 0) { Uri uri = new Uri.Builder().scheme("terse").path(links.get(position)).build(); Intent intent = new Intent("android.intent.action.MAIN", uri); intent.setClass(getApplicationContext(), TerseActivity.class); startActivity(intent); } } // } // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), // Toast.LENGTH_SHORT).show(); } }); setContentView(listv); return; } else if (type.str.equals("edit") && value instanceof Str) { final EditText ed = new EditText(this); ed.setText(taSaveMe == null ? value.toString() : taSaveMe); ed.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); ed.setLayoutParams(widgetParams); // ed.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); ed.setTextAppearance(this, R.style.teletype); ed.setBackgroundColor(Color.BLACK); ed.setGravity(Gravity.TOP); ed.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET); ed.setVerticalFadingEdgeEnabled(true); ed.setVerticalScrollBarEnabled(true); ed.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" // button // if ((event.getAction() == KeyEvent.ACTION_DOWN) // && // (keyCode == KeyEvent.KEYCODE_ENTER)) { // // Perform action on key press // Toast.makeText(TerseActivity.this, ed.getText(), // Toast.LENGTH_SHORT).show(); // return true; // } return false; } }); Button btn = new Button(this); btn.setText("Save"); btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks String text = ed.getText().toString(); text = Parser.charSubsts(text); Toast.makeText(TerseActivity.this, text, Toast.LENGTH_SHORT).show(); String action = stringAt(d, "action"); String query = ""; String f1 = stringAt(d, "field1"); String v1 = stringAt(d, "value1"); String f2 = stringAt(d, "field2"); String v2 = stringAt(d, "value2"); f1 = (f1 == null) ? "f1null" : f1; v1 = (v1 == null) ? "v1null" : v1; f2 = (f2 == null) ? "f2null" : f2; v2 = (v2 == null) ? "v2null" : v2; startTerseActivity(action, query, stringAt(d, "field1"), stringAt(d, "value1"), stringAt(d, "field2"), stringAt(d, "value2"), "text", text); } }); LinearLayout linear = new LinearLayout(this); linear.setOrientation(LinearLayout.VERTICAL); linear.addView(btn); linear.addView(ed); setContentView(linear); return; } else if (type.str.equals("draw") && value instanceof Vec) { Vec v = ((Vec) value); DrawView dv = new DrawView(this, v.vec, d); dv.setLayoutParams(widgetParams); setContentView(dv); return; } else if (type.str.equals("live")) { Blk blk = value.mustBlk(); Blk event = Static.urAt(d, "event").asBlk(); TerseSurfView tsv = new TerseSurfView(this, blk, event); setContentView(tsv); return; } else if (type.str.equals("fnord")) { Blk blk = value.mustBlk(); Blk event = Static.urAt(d, "event").asBlk(); FnordView fnord = new FnordView(this, blk, event); setContentView(fnord); return; } else if (type.str.equals("world") && value instanceof Str) { String newWorld = value.toString(); if (Terp.WORLD_P.matcher(newWorld).matches()) { world = newWorld; resetTerp(); explain = Static.fmt("Switching to world <%s>\nUse menu to go Home.", world); Toast.makeText(getApplicationContext(), explain, Toast.LENGTH_LONG).show(); } else { terp.toss("Bad world syntax (must be 3 letters then 0 to 3 digits: <%s>", newWorld); } // Fall thru for explainv.setText(explain). } else if (type.str.equals("text")) { explain = "<<< " + title + " >>>\n\n" + value.toString(); // Fall thru for explainv.setText(explain). } else if (type.str.equals("html")) { final WebView webview = new WebView(this); // webview.loadData(value.toString(), "text/html", null); webview.loadDataWithBaseURL("terse://terse", value.toString(), "text/html", "UTF-8", null); webview.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // terp.say("WebView UrlLoading: url=%s", url); URI uri = URI.create("" + url); // terp.say("WebView UrlLoading: URI=%s", uri); terp.say("WebView UrlLoading: getPath=%s", uri.getPath()); terp.say("WebView UrlLoading: getQuery=%s", uri.getQuery()); // Toast.makeText(getApplicationContext(), // uri.toASCIIString(), Toast.LENGTH_SHORT) // .show(); // webview.invalidate(); // // TextView quick = new // TextView(TerseActivity.this); // quick.setText(uri.toASCIIString()); // quick.setBackgroundColor(Color.BLACK); // quick.setTextColor(Color.WHITE); // setContentView(quick); startTerseActivity(uri.getPath(), uri.getQuery()); return true; } }); // webview.setWebChromeClient(new WebChromeClient()); webview.getSettings().setBuiltInZoomControls(true); // webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setDefaultFontSize(18); webview.getSettings().setNeedInitialFocus(true); webview.getSettings().setSupportZoom(true); webview.getSettings().setSaveFormData(true); setContentView(webview); // ScrollView scrollv = new ScrollView(this); // scrollv.addView(webview); // setContentView(scrollv); return; } else { explain = "Unknown page type: " + type.str + " with vaule type: " + value.cls + "\n\n##############\n\n"; explain += value.toString(); // Fall thru for explainv.setText(explain). } } catch (Exception ex) { ex.printStackTrace(); explain = Static.describe(ex); } } TextView explainv = new TextView(this); explainv.setText(explain); explainv.setBackgroundColor(Color.BLACK); explainv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24); explainv.setTextColor(Color.YELLOW); SetContentViewWithHomeButtonAndScroll(explainv); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptVNCAllowExternal(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Enable VNC server"); TextView textView = new TextView(activity); textView.setVisibility(View.VISIBLE); textView.setId(201012010);/* w w w. ja v a2s. c om*/ textView.setText("VNC Server: " + this.getLocalIpAddress() + ":" + "5901\n" + "Warning: VNC is not secure make sure you're on a private network!\n"); EditText passwdView = new EditText(activity); passwdView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwdView.setHint("Password"); passwdView.setEnabled(true); passwdView.setVisibility(View.VISIBLE); passwdView.setId(11111); passwdView.setSingleLine(); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222); RelativeLayout.LayoutParams textViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, mLayout.getId()); mLayout.addView(textView, textViewParams); RelativeLayout.LayoutParams passwordViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); passwordViewParams.addRule(RelativeLayout.BELOW, textView.getId()); // passwordViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, // mLayout.getId()); mLayout.addView(passwdView, passwordViewParams); alertDialog.setView(mLayout); final Handler handler = this.handler; alertDialog.setButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(11111); if (a.getText().toString().trim().equals("")) { Toast.makeText(getApplicationContext(), "Password cannot be empty!", Toast.LENGTH_SHORT).show(); vnc_passwd = null; vnc_allow_external = 0; mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); return; } else { sendHandlerMessage(handler, Const.VNC_PASSWORD, "vnc_passwd", "passwd"); vnc_passwd = a.getText().toString(); vnc_allow_external = 1; // LimboSettingsManager.setVNCAllowExternal(activity, true); } } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { vnc_passwd = null; vnc_allow_external = 0; mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); vnc_passwd = null; vnc_allow_external = 0; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMachineName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Machine Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from www.j av a 2 s .c o m searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.VM_CREATED, "machine_name", a.getText().toString()); return; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptStateName(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Snapshot/State Name"); EditText searchView = new EditText(activity); searchView.setEnabled(true);//from w w w . j a va 2 s. c o m searchView.setVisibility(View.VISIBLE); searchView.setId(201012010); searchView.setSingleLine(); alertDialog.setView(searchView); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); sendHandlerMessage(handler, Const.SNAPSHOT_CREATED, new String[] { "snapshot_name" }, new String[] { a.getText().toString() }); return; } }); alertDialog.show(); }
From source file:org.smilec.smile.student.CourseList.java
void MakeQuestion() { curcategory = category_arr[0];//from w w w . j av a 2 s . c o m setTitle(curcategory); setContentView(R.layout.mkquestion); imageview = (ImageView) findViewById(R.id.galleryimg01); final EditText myContent = (EditText) findViewById(R.id.mkqContent); final EditText myOp1 = (EditText) findViewById(R.id.op1); final EditText myOp2 = (EditText) findViewById(R.id.op2); final EditText myOp3 = (EditText) findViewById(R.id.op3); final EditText myOp4 = (EditText) findViewById(R.id.op4); rgb04 = (RadioGroup) findViewById(R.id.rgroup04); // for inserting right answer // if (galleryidx == 1) SaveImage(); // retain the previous contents for preview if ((previewidx == 1) || (galleryidx == 1)) { galleryidx = 0; myContent.setText(question_arr[0]); myOp1.setText(question_arr[1]); myOp2.setText(question_arr[2]); myOp3.setText(question_arr[3]); myOp4.setText(question_arr[4]); if (question_arr[5] != null && question_arr[5] != "") rgb04.check(Integer.parseInt(question_arr[5]) + R.id.rightan01 - 1); imageview.setImageBitmap(_bmImg); } // Add Image ImageButton addimg = (ImageButton) findViewById(R.id.camera01); addimg.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { // retain the previous information int checked_rid = rgb04.getCheckedRadioButtonId(); int my_an = checked_rid - R.id.rightan01 + 1; myRightan = Integer.toString(my_an); String _content = myContent.getText().toString(); String _op1 = myOp1.getText().toString(); String _op2 = myOp2.getText().toString(); String _op3 = myOp3.getText().toString(); String _op4 = myOp4.getText().toString(); String _rightan = myRightan; question_arr[0] = _content; question_arr[1] = _op1; question_arr[2] = _op2; question_arr[3] = _op3; question_arr[4] = _op4; question_arr[5] = _rightan; //---------------------------------------------------------- image_qa = new QuickAction(v); image_qa.addActionItem(image_first); image_qa.addActionItem(image_second); image_qa.addActionItem(image_third); image_qa.show(); } }); // save a question made by student (ok = 1, cancel = 2, post+makeQuestion = 3) Button post1 = (Button) findViewById(R.id.post01); post1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { final Builder adb = new AlertDialog.Builder(CourseList.this); adb.setTitle(curcategory); adb.setMessage(getString(R.string.post_q)); adb.setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { int checked_rid = rgb04.getCheckedRadioButtonId(); int my_an = checked_rid - R.id.rightan01 + 1; if (my_an < 0) { /*Toast.makeText(CourseList.this, getString(R.string.error_noanswer), Toast.LENGTH_SHORT).show();*/ showToast(getString(R.string.error_noanswer)); } else { myRightan = Integer.toString(my_an); if (bmImg != null) { ByteArrayOutputStream jpg = new ByteArrayOutputStream(64 * 1024); boolean error = bmImg.compress(Bitmap.CompressFormat.JPEG, 100, jpg); if (!error) Log.d(APP_TAG, "ERROR JPEG"); // post with picture student.post_question_to_teacher_picture(myContent.getText().toString(), myOp1.getText().toString(), myOp2.getText().toString(), myOp3.getText().toString(), myOp4.getText().toString(), myRightan, jpg.toByteArray()); } else { // post it without picture student.post_question_to_teacher(myContent.getText().toString(), myOp1.getText().toString(), myOp2.getText().toString(), myOp3.getText().toString(), myOp4.getText().toString(), myRightan); } Log.d(APP_TAG, "Posting:" + myContent.getText().toString()); // after posting question, return the main // screen if (previewidx == 1) { previewidx = 0; _bmImg = null; } show_todo_view(); selarridx = 0; } } }); // Cancel to post the question adb.setNegativeButton(getString(R.string.Cancel), null); // Post and make the question adb.setNeutralButton(getString(R.string.Post_MoreQ), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { int checked_rid = rgb04.getCheckedRadioButtonId(); int my_an = checked_rid - R.id.rightan01 + 1; if (my_an < 0) { /*Toast.makeText(CourseList.this, getString(R.string.error_noanswer), Toast.LENGTH_SHORT).show();*/ showToast(getString(R.string.error_noanswer)); } else { myRightan = Integer.toString(my_an); if (bmImg != null) { ByteArrayOutputStream jpg = new ByteArrayOutputStream(64 * 1024); boolean error = bmImg.compress(Bitmap.CompressFormat.JPEG, 100, jpg); if (!error) Log.d(APP_TAG, "ERROR JPGE"); // post with picture student.post_question_to_teacher_picture(myContent.getText().toString(), myOp1.getText().toString(), myOp2.getText().toString(), myOp3.getText().toString(), myOp4.getText().toString(), myRightan, jpg.toByteArray()); } else { // post it without picture student.post_question_to_teacher(myContent.getText().toString(), myOp1.getText().toString(), myOp2.getText().toString(), myOp3.getText().toString(), myOp4.getText().toString(), myRightan); } Log.d(APP_TAG, "Posting:" + myContent.getText().toString()); if (previewidx == 1) { previewidx = 0; _bmImg = null; chkimg = 0; bmImg = null; } chkimg = 0; selarridx = 0; bmImg = null; MakeQuestion(); } } }); AlertDialog d = adb.show(); smile.overrideFonts(activity, d.findViewById(android.R.id.content)); } }); // Preview the newly created question Button preview1 = (Button) findViewById(R.id.preview01); preview1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { previewidx = 1; int checked_rid = rgb04.getCheckedRadioButtonId(); int my_an = checked_rid - R.id.rightan01 + 1; myRightan = Integer.toString(my_an); String _content = myContent.getText().toString(); String _op1 = myOp1.getText().toString(); String _op2 = myOp2.getText().toString(); String _op3 = myOp3.getText().toString(); String _op4 = myOp4.getText().toString(); String _rightan = myRightan; question_arr[0] = _content; question_arr[1] = _op1; question_arr[2] = _op2; question_arr[3] = _op3; question_arr[4] = _op4; question_arr[5] = _rightan; preview(_content, _op1, _op2, _op3, _op4); } }); }