List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:com.cybrosys.scientific.EventListener.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override//from w w w .java2 s.co m public void onClick(View vwView) { vibrate(); ctx = PalmCalcActivity.ctx; int id = vwView.getId(); ScientificActivity.txtvShift.setText(""); switch (id) { case R.id.buttonDel: mHandler.onDelete(); break; case R.id.button3: if (inShift == 0) mHandler.insert("3"); else { mHandler.insert(","); inShift = 0; } break; case R.id.buttonDot: if (inShift == 0) mHandler.insert("."); else { showD(); inShift = 0; } break; case R.id.buttonAC: mHandler.onClear(); break; case R.id.ButtonEqual: String strDisplayEq = mHandler.getDisplayText(); if (!strDisplayEq.equalsIgnoreCase("")) mHandler.onEnter(); break; case R.id.ButtonAns: if (inShift == 0) mHandler.onShow(); else { showHistory(); inShift = 0; } break; case R.id.buttonDeg: mHandler.onDegChange(); break; case R.id.buttonAlt: if (inShift == 0) { String[] strMode = new String[] { "Floatpt", "FIX", "SCI" }; int inSizeM = 3; LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vwLayout = inflater.inflate(R.layout.pop_history, (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element)); TextView txtvHeaderPop = (TextView) vwLayout.findViewById(R.id.txtvHeaderPop); txtvHeaderPop.setText("MODE"); popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW1.setBackgroundDrawable(new BitmapDrawable()); popmW1.setOutsideTouchable(true); popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0); tblltTable = (TableLayout) vwLayout.findViewById(R.id.tablelay); ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); } }); txtvHistory = new TextView[inSizeM]; btnHistory = new Button[inSizeM]; tblrRowL = new TableRow[inSizeM]; TableRow.LayoutParams buttonParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f); TableRow.LayoutParams textParams = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT, .1f); int inJ = 0; for (int inI = 0; inI < inSizeM; inI++) { btnHistory[inJ] = new Button(ctx); txtvHistory[inJ] = new TextView(ctx); txtvHistory[inJ].setText("" + (inJ + 1)); txtvHistory[inJ].setLayoutParams(textParams); btnHistory[inJ].setText(strMode[inI]); txtvHistory[inJ].setGravity(Gravity.CENTER); txtvHistory[inJ] .setTextColor(ScientificActivity.ctx.getResources().getColor(R.color.HistColor)); btnHistory[inJ].setTextColor(Color.WHITE); btnHistory[inJ].setGravity(Gravity.LEFT); btnHistory[inJ].setLayoutParams(buttonParams); btnHistory[inJ].setBackgroundDrawable(ctx.getResources().getDrawable(R.drawable.button_effect)); tblrRowL[inJ] = new TableRow(ctx); tblrRowL[inJ].addView(txtvHistory[inJ]); tblrRowL[inJ].addView(btnHistory[inJ]); tblltTable.addView(tblrRowL[inJ]); final int inK = inJ; btnHistory[inK].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // etxt.setText(btns[inK].getText().toString()); ScientificActivity.txtvFSE.setText(btnHistory[inK].getText().toString()); popmW1.dismiss(); } }); inJ++; } } else { setFSE(); inShift = 0; } mHandler.onFSEChange(); break; case R.id.buttonShift: if (inShift == 0) { inShift = 1; mHandler.onShiftPress(); } else inShift = 0; break; case R.id.buttonHyp: if (inHyp == 0) { inHyp = 1; mHandler.onHypPress(); } else { inHyp = 0; ScientificActivity.txtvHyp.setText(""); } break; case R.id.buttonMS: mHandler.onEnter(); String strDisplay = mHandler.getDisplayText(); if (inShift == 0) { if (isValidNumber(strDisplay)) { PreferenceClass.setMyStringPref(ctx, strDisplay); Toast.makeText(ctx, "Memory Saved!", Toast.LENGTH_SHORT).show(); mHandler.onClear(); } else Toast.makeText(ctx, "Save Failed!", Toast.LENGTH_SHORT).show(); } else { Memstore(); } break; case R.id.buttonMR: if (inShift == 0) { String strPref = PreferenceClass.getMyStringPref(ctx); if (!strPref.equalsIgnoreCase("")) { mHandler.insert(strPref); } else Toast.makeText(ctx, "Empty", Toast.LENGTH_SHORT).show(); } else { Memread(); inShift = 0; } break; case R.id.buttonMp: mHandler.onEnter(); String strDisplay2 = mHandler.getDisplayText(); if (isValidNumber(strDisplay2)) { String strPref2 = PreferenceClass.getMyStringPref(ctx); if (!strPref2.equalsIgnoreCase("")) { if (inShift == 0) { try { PreferenceClass.setMyStringPref(ctx, "" + mSymbols.eval(strPref2 + "+" + strDisplay2)); mHandler.onClear(); } catch (SyntaxException e) { e.printStackTrace(); } Toast.makeText(ctx, "Value added", Toast.LENGTH_SHORT).show(); } else { Memplus(); inShift = 0; } } } break; default: if (vwView instanceof Button) { String strText = ((Button) vwView).getTag().toString(); if (strText.contains(",")) { int inInComa = strText.lastIndexOf(","); if (inShift == 1) { strText = strText.substring(inInComa + 1, strText.length()); inShift = 0; } else { strText = strText.substring(0, inInComa); } } if (inHyp == 1) { if (strText.contains("sin(")) { strText = strText.replace("sin(", "sinh("); } if (strText.contains("cos(")) { strText = strText.replace("cos(", "cosh("); } if (strText.contains("tan(")) { strText = strText.replace("tan(", "tanh("); } ScientificActivity.txtvHyp.setText(""); inHyp = 0; } mHandler.insert(strText); } } }
From source file:com.activiti.android.ui.fragments.task.TaskDetailsFoundationFragment.java
protected void displayCheckList(List<TaskRepresentation> taskRepresentations) { if (getVersionNumber() < ActivitiVersionNumber.VERSION_1_3_0) { hide(R.id.task_details_checklist_card); return;//ww w. ja va 2 s .c om } show(R.id.task_details_checklist_card); if (taskRepresentations == null || taskRepresentations.isEmpty() || isEnded) { hide(R.id.task_details_checklist_card); return; } LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // TASKS LinearLayout activeTaskContainer = (LinearLayout) viewById(R.id.task_details_checklist_container); activeTaskContainer.removeAllViews(); View v; if (taskRepresentations == null || taskRepresentations.isEmpty()) { v = inflater.inflate(R.layout.row_single_line, activeTaskContainer, false); ((TextView) v.findViewById(R.id.toptext)).setText(R.string.task_help_add_first_checklist); HolderUtils.makeMultiLine(((TextView) v.findViewById(R.id.toptext)), 4); v.findViewById(R.id.icon).setVisibility(View.GONE); activeTaskContainer.addView(v); } else { TaskRepresentation taskCheckList; TwoLinesViewHolder vh; int max = (taskRepresentations.size() > TASKS_MAX_ITEMS) ? TASKS_MAX_ITEMS : taskRepresentations.size(); for (int i = 0; i < max; i++) { taskCheckList = taskRepresentations.get(i); v = inflater.inflate(R.layout.row_three_lines_caption_borderless, activeTaskContainer, false); v.setTag(taskCheckList); vh = HolderUtils.configure(v, taskCheckList.getName(), null, TaskAdapter.createAssigneeInfo(getActivity(), taskCheckList), TaskAdapter.createRelativeDateInfo(getActivity(), taskCheckList), R.drawable.ic_account_circle_grey); if (taskCheckList.getEndDate() != null) { vh.choose.setImageResource(R.drawable.ic_done_grey); } else { vh.choose.setImageResource(android.R.color.transparent); } vh.choose.setVisibility(View.VISIBLE); activeTaskContainer.addView(v); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TaskDetailsFragment.with(getActivity()).task((TaskRepresentation) v.getTag()) .bindFragmentTag(getTag()).back(true).display(); } }); } } }
From source file:com.housekeeper.ar.healthhousekeeper.RegisterActivity.java
private void setSpinner() { Log.i(TAG, "namePros:" + namePros); // ArrayAdapter<String> proAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,namePros){ // @Override // public View getDropDownView(int position, View convertView, ViewGroup parent) { // LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(R.layout.spinner_item_layout, // null); // TextView label = (TextView) view // .findViewById(R.id.spinner_item_label); ////from w w w. j av a2 s . co m // label.setText(namePros[position]); // // // return view; // //return super.getDropDownView(position, convertView, parent); // } // }; // // //? // proAdapter.setDropDownViewResource(R.layout.spinner_item_layout); //// proAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // pro.setAdapter(proAdapter); // pro.setOnItemSelectedListener(new OnItemSelectedListener() { // // @Override // public void onItemSelected(AdapterView<?> parent, View view, // int position, long id) { // // TODO Auto-generated method stub // proStr = parent.getItemAtPosition(position).toString(); // Log.v(TAG, "selcet proStr:" + proStr); // if (proStr.equals(namePros[position])) { // idJobTitlesInt = idJobTitles[position]; // } // } // // @Override // public void onNothingSelected(AdapterView<?> arg0) { // // TODO Auto-generated method stub // // } // // }); // // pro.setOnTouchListener(new View.OnTouchListener() { // @Override // public boolean onTouch(View view, MotionEvent motionEvent) { // // Log.i(TAG, "year touch "); // closeSoftKeyboard(); // return false; // } // }); ArrayAdapter<String> shengAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, nameProvinces) { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.spinner_item_layout, null); TextView label = (TextView) view.findViewById(R.id.spinner_item_label); label.setText(nameProvinces[position]); return view; //return super.getDropDownView(position, convertView, parent); } }; //? shengAdapter.setDropDownViewResource(R.layout.spinner_item_layout); sheng.setAdapter(shengAdapter); sheng.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> shengparent, View shengview, int shengposition, long shengid) { // TODO Auto-generated method stub myApp.setShengposition(shengposition); shengStr = shengparent.getItemAtPosition(shengposition).toString(); Log.v(TAG, "shengStr:" + shengStr); if (!shengStr.equals("") && shengStr.equals(nameProvinces[shengposition])) { Log.v(TAG, "position:" + shengposition); for (int i = 0; i < joProvinces.length; i++) { try { if (shengStr.equals(joProvinces[i].getString("name"))) { jaCities = joProvinces[i].getJSONArray("cities"); joCities = new JSONObject[jaCities.length()]; nameCities = new String[joCities.length]; for (int j = 0; j < jaCities.length(); j++) { joCities[j] = jaCities.getJSONObject(j); nameCities[j] = joCities[j].getString("name"); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } sheng.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { Log.i(TAG, "year touch "); closeSoftKeyboard(); return false; } }); shiAdapter = new ArrayAdapter<String>(RegisterActivity.this, R.layout.spinner_item, nameCities) { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.spinner_item_layout, null); TextView label = (TextView) view.findViewById(R.id.spinner_item_label); label.setText(nameCities[position]); return view; //return super.getDropDownView(position, convertView, parent); } }; //? shiAdapter.setDropDownViewResource(R.layout.spinner_item_layout); // shiAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); shi.setAdapter(shiAdapter); shi.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> shiparent, View shiview, int shiposition, long shiid) { // TODO Auto-generated method stub shiStr = shiparent.getItemAtPosition(shiposition).toString(); Log.v(TAG, "shiStr:" + shiStr); if (!shiStr.equals("") && shiStr.equals(nameCities[shiposition])) { for (int i = 0; i < joCities.length; i++) { try { if (shiStr.equals(joCities[i].getString("name"))) { jaHospitals = joCities[i].getJSONArray("hospitals"); joHospitals = new JSONObject[jaHospitals.length()]; nameHospitals = new String[joHospitals.length]; for (int j = 0; j < jaHospitals.length(); j++) { joHospitals[j] = jaHospitals.getJSONObject(j); nameHospitals[j] = joHospitals[j].getString("name"); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } shi.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { Log.i(TAG, "year touch "); closeSoftKeyboard(); return false; } }); hospitalAdapter = new ArrayAdapter<String>(RegisterActivity.this, R.layout.spinner_item, nameHospitals) { @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.spinner_item_layout, null); TextView label = (TextView) view.findViewById(R.id.spinner_item_label); label.setText(nameHospitals[position]); return view; //return super.getDropDownView(position, convertView, parent); } }; //? hospitalAdapter.setDropDownViewResource(R.layout.spinner_item_layout); yy.setAdapter(hospitalAdapter); yy.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> yyparent, View yyview, int yyposition, long yyid) { // TODO Auto-generated method stub yyStr = yyparent.getItemAtPosition(yyposition).toString(); if (!yyStr.equals("") && yyStr.equals(nameHospitals[yyposition])) { for (int i = 0; i < joHospitals.length; i++) { try { if (yyStr.equals(joHospitals[i].getString("name"))) { jaDepartments = joHospitals[i].getJSONArray("departments"); joDepartments = new JSONObject[jaDepartments.length()]; nameDepartments = new String[joDepartments.length]; idDepartments = new int[joDepartments.length]; for (int j = 0; j < jaDepartments.length(); j++) { joDepartments[j] = jaDepartments.getJSONObject(j); nameDepartments[j] = joDepartments[j].getString("name"); idDepartments[j] = joDepartments[j].getInt("id"); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } yy.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { Log.i(TAG, "year touch "); closeSoftKeyboard(); return false; } }); // departmentAdapter = new ArrayAdapter<String>(RegisterActivity.this, android.R.layout.simple_spinner_item, nameDepartments) { // @Override // public View getDropDownView(int position, View convertView, ViewGroup parent) { // LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // View view = inflater.inflate(R.layout.spinner_item_layout, // null); // TextView label = (TextView) view // .findViewById(R.id.spinner_item_label); // // label.setText(nameDepartments[position]); // // // return view; // //return super.getDropDownView(position, convertView, parent); // } // }; //? // departmentAdapter.setDropDownViewResource(R.layout.spinner_item_layout); // ks.setAdapter(departmentAdapter); // ks.setOnItemSelectedListener(new OnItemSelectedListener() { // // @Override // public void onItemSelected( // AdapterView<?> ksparent, View ksview, // int ksposition, long ksid) { // // TODO Auto-generated method stub // ksStr = ksparent.getItemAtPosition(ksposition).toString(); // if (ksStr.equals(nameDepartments[ksposition])) { // try { // idDepartmentInt = idDepartments[ksposition]; // joDepartmentType = joDepartments[ksposition].getJSONObject("departmentType"); // departmentTypeTv.setText(joDepartmentType.getString("name")); // } catch (JSONException e) { // // TODO Auto-generated catch block // // e.printStackTrace(); // } // } // } // // @Override // public void onNothingSelected( // AdapterView<?> arg0) { // // TODO Auto-generated method stub // // } // }); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); // ks.setOnTouchListener(new View.OnTouchListener() { // @Override // public boolean onTouch(View view, MotionEvent motionEvent) { // // Log.i(TAG, "year touch "); // closeSoftKeyboard(); // return false; // } // }); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); year.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub yearStr = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); month.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub monthStr = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); day.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub dayStr = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); sex.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub sexStr = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); }
From source file:ar.com.tristeslostrestigres.diasporanativewebapp.MainActivity.java
public void alertFormElements() { /*/*from www . ja v a 2s. co m*/ * Inflate the XML view. activity_main is in * res/layout/form_elements.xml */ LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View formElementsView = inflater.inflate(R.layout.font_size_chooser, null, false); final RadioGroup rgFontSize = (RadioGroup) formElementsView.findViewById(R.id.genderRadioGroup); // the alert dialog new AlertDialog.Builder(MainActivity.this).setView(formElementsView).setTitle("Set Font Size") .setNegativeButton("OK", new DialogInterface.OnClickListener() { @TargetApi(11) public void onClick(DialogInterface dialog, int id) { int selectedId = rgFontSize.getCheckedRadioButtonId(); // find the radiobutton by returned id RadioButton selectedRadioButton = (RadioButton) formElementsView.findViewById(selectedId); if (selectedRadioButton.getId() == R.id.radNormal) { pm.setMinimumFontSize(8); } else if (selectedRadioButton.getId() == R.id.radLarge) { pm.setMinimumFontSize(16); } else if (selectedRadioButton.getId() == R.id.radLarger) { pm.setMinimumFontSize(20); } wSettings.setMinimumFontSize(pm.getMinimumFontSize()); if (Helpers.isOnline(MainActivity.this)) { webView.loadUrl(webView.getUrl()); } else { Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_LONG).show(); } dialog.cancel(); } }).show(); }
From source file:com.activiti.android.ui.fragments.task.TaskDetailsFoundationFragment.java
private void createHelpSection() { if (isEnded) { return;/*from w w w .j a va2s . c o m*/ } show(R.id.task_details_help_card); // DETAILS LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout helpContainer = (LinearLayout) viewById(R.id.task_details_help_card); helpContainer.removeAllViews(); View v = inflater.inflate(R.layout.card_task_help, helpContainer, false); // INVOLVE TwoLinesViewHolder vh = HolderUtils.configure(v.findViewById(R.id.help_details_involve), getString(R.string.task_help_add_people), null, R.drawable.ic_account_box_grey); HolderUtils.makeMultiLine(vh.topText, 3); v.findViewById(R.id.help_details_involve_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Special case activiti.alfresco.com & tenantid == null // User must pick user via email only startInvolveAction(); } }); // ADD CONTENT vh = HolderUtils.configure(v.findViewById(R.id.help_details_add_content), getString(R.string.task_help_add_content), null, R.drawable.ic_insert_drive_file_grey); HolderUtils.makeMultiLine(vh.topText, 3); v.findViewById(R.id.help_details_add_content_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ContentTransferManager.requestGetContent(TaskDetailsFoundationFragment.this); } }); // COMMENT vh = HolderUtils.configure(v.findViewById(R.id.help_details_comment), getString(R.string.task_help_add_comment), null, R.drawable.ic_insert_comment_grey); HolderUtils.makeMultiLine(vh.topText, 3); v.findViewById(R.id.help_details_comment_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity) getActivity()) .setRightMenuVisibility(!((MainActivity) getActivity()).isRightMenuVisible()); } }); // CHECKLIST vh = HolderUtils.configure(v.findViewById(R.id.help_details_add_task_checklist), getString(R.string.task_help_add_checklist), null, R.drawable.ic_add_circle_grey); HolderUtils.makeMultiLine(vh.topText, 3); v.findViewById(R.id.help_details_add_task_checklist_container) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CreateStandaloneTaskDialogFragment.with(getActivity()).taskId(taskRepresentation.getId()) .displayAsDialog(); } }); helpContainer.addView(v); }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
@SuppressLint("InflateParams") private void optionTemplate() { final int userId = Util.getUserId(Process.myUid()); // Build view LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.template, null); final Spinner spTemplate = (Spinner) view.findViewById(R.id.spTemplate); Button btnRename = (Button) view.findViewById(R.id.btnRename); ExpandableListView elvTemplate = (ExpandableListView) view.findViewById(R.id.elvTemplate); // Template selector final SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); String defaultName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, "0", getString(R.string.title_default)); spAdapter.add(defaultName);// www . ja v a 2 s . c o m for (int i = 1; i <= 4; i++) { String alternateName = PrivacyManager.getSetting(userId, Meta.cTypeTemplateName, Integer.toString(i), getString(R.string.title_alternate) + " " + i); spAdapter.add(alternateName); } spTemplate.setAdapter(spAdapter); // Template definition final TemplateListAdapter templateAdapter = new TemplateListAdapter(this, view, R.layout.templateentry); elvTemplate.setAdapter(templateAdapter); elvTemplate.setGroupIndicator(null); spTemplate.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { templateAdapter.notifyDataSetChanged(); } @Override public void onNothingSelected(AdapterView<?> arg0) { templateAdapter.notifyDataSetChanged(); } }); btnRename.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (Util.hasProLicense(ActivityMain.this) == null) { // Redirect to pro page Util.viewUri(ActivityMain.this, cProUri); return; } final int templateId = spTemplate.getSelectedItemPosition(); if (templateId == AdapterView.INVALID_POSITION) return; AlertDialog.Builder dlgRename = new AlertDialog.Builder(spTemplate.getContext()); dlgRename.setTitle(R.string.title_rename); final String original = (templateId == 0 ? getString(R.string.title_default) : getString(R.string.title_alternate) + " " + templateId); dlgRename.setMessage(original); final EditText input = new EditText(spTemplate.getContext()); dlgRename.setView(input); dlgRename.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String name = input.getText().toString(); if (TextUtils.isEmpty(name)) { PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId), null); name = original; } else { PrivacyManager.setSetting(userId, Meta.cTypeTemplateName, Integer.toString(templateId), name); } spAdapter.remove(spAdapter.getItem(templateId)); spAdapter.insert(name, templateId); spAdapter.notifyDataSetChanged(); } }); dlgRename.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing } }); dlgRename.create().show(); } }); // Build dialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.menu_template); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setView(view); alertDialogBuilder.setPositiveButton(getString(R.string.msg_done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); // Show dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** Called when the activity is first created. * Usually, the input parameter oSavedInstanceState is null. However, if the activity has already * started, and then sent to the background, and destroyed due to low memory, when the * settingsActivity is brought to foreground again, the parameter will contain the pending ui * change, we need to apply those change to UI to follow the Android design guide line. */// w w w.j a va 2s . c o m @Override public void onCreate(Bundle oSavedInstanceState) { super.onCreate(oSavedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); m_oInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); populateRegistrationMethods(); }
From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/*from w w w . j a v a2 s . co m*/ ProgressDialog pdialog; AlertDialog.Builder builder; LayoutInflater inflater; View layout; // used for inflated views for AlertDialog.Builder.setView() switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, false) { @Override public void onLoginChosen(String user, String password) { dismissDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_COMPOSE: inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); builder = new AlertDialog.Builder(this); layout = inflater.inflate(R.layout.compose_dialog, null); final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input); final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input); final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input); final Button composeSendButton = (Button) layout.findViewById(R.id.compose_send_button); final Button composeCancelButton = (Button) layout.findViewById(R.id.compose_cancel_button); final EditText composeCaptcha = (EditText) layout.findViewById(R.id.compose_captcha_input); composeDestination.setText(mUsername); dialog = builder.setView(layout).create(); final Dialog composeDialog = dialog; composeSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { ThingInfo hi = new ThingInfo(); // reddit.com performs these sanity checks too. if ("".equals(composeDestination.getText().toString().trim())) { Toast.makeText(ProfileActivity.this, "please enter a username", Toast.LENGTH_LONG).show(); return; } if ("".equals(composeSubject.getText().toString().trim())) { Toast.makeText(ProfileActivity.this, "please enter a subject", Toast.LENGTH_LONG).show(); return; } if ("".equals(composeText.getText().toString().trim())) { Toast.makeText(ProfileActivity.this, "you need to enter a message", Toast.LENGTH_LONG) .show(); return; } if (composeCaptcha.getVisibility() == View.VISIBLE && "".equals(composeCaptcha.getText().toString().trim())) { Toast.makeText(ProfileActivity.this, "", Toast.LENGTH_LONG).show(); return; } hi.setDest(composeDestination.getText().toString().trim()); hi.setSubject(composeSubject.getText().toString().trim()); new MyMessageComposeTask(composeDialog, hi, composeCaptcha.getText().toString().trim()) .execute(composeText.getText().toString().trim()); dismissDialog(Constants.DIALOG_COMPOSE); } }); composeCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { dismissDialog(Constants.DIALOG_COMPOSE); } }); break; case Constants.DIALOG_THREAD_CLICK: inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); builder = new AlertDialog.Builder(this); dialog = builder.setView(inflater.inflate(R.layout.thread_click_dialog, null)).create(); break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(this); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(false); dialog = pdialog; break; case Constants.DIALOG_REPLYING: pdialog = new ProgressDialog(this); pdialog.setMessage("Sending reply..."); pdialog.setIndeterminate(true); pdialog.setCancelable(false); dialog = pdialog; break; case Constants.DIALOG_COMPOSING: pdialog = new ProgressDialog(this); pdialog.setMessage("Composing message..."); pdialog.setIndeterminate(true); pdialog.setCancelable(false); dialog = pdialog; break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }
From source file:com.andrewshu.android.reddit.user.ProfileActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;//from w w w . j a v a 2s .c o m ProgressDialog pdialog; AlertDialog.Builder builder; LayoutInflater inflater; View layout; // used for inflated views for AlertDialog.Builder.setView() switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, false) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; case Constants.DIALOG_COMPOSE: inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme())); layout = inflater.inflate(R.layout.compose_dialog, null); Common.setTextColorFromTheme(mSettings.getTheme(), getResources(), (TextView) layout.findViewById(R.id.compose_destination_textview), (TextView) layout.findViewById(R.id.compose_subject_textview), (TextView) layout.findViewById(R.id.compose_message_textview), (TextView) layout.findViewById(R.id.compose_captcha_textview), (TextView) layout.findViewById(R.id.compose_captcha_loading)); final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input); final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input); final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input); final Button composeSendButton = (Button) layout.findViewById(R.id.compose_send_button); final Button composeCancelButton = (Button) layout.findViewById(R.id.compose_cancel_button); final EditText composeCaptcha = (EditText) layout.findViewById(R.id.compose_captcha_input); composeDestination.setText(mUsername); dialog = builder.setView(layout).create(); final Dialog composeDialog = dialog; composeSendButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { ThingInfo hi = new ThingInfo(); if (!FormValidation.validateComposeMessageInputFields(ProfileActivity.this, composeDestination, composeSubject, composeText, composeCaptcha)) return; hi.setDest(composeDestination.getText().toString().trim()); hi.setSubject(composeSubject.getText().toString().trim()); new MyMessageComposeTask(composeDialog, hi, composeCaptcha.getText().toString().trim()) .execute(composeText.getText().toString().trim()); removeDialog(Constants.DIALOG_COMPOSE); } }); composeCancelButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { removeDialog(Constants.DIALOG_COMPOSE); } }); break; case Constants.DIALOG_THREAD_CLICK: dialog = new ThreadClickDialog(this, mSettings); break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_REPLYING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Sending reply..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_COMPOSING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Composing message..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; default: throw new IllegalArgumentException("Unexpected dialog id " + id); } return dialog; }
From source file:com.cybrosys.scientific.EventListener.java
@SuppressWarnings("deprecation") private void Memread() { spMemory = ctx.getSharedPreferences(PREFNAME, 0); LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); vwLayout = inflater.inflate(R.layout.memory, (ViewGroup) ((Activity) ctx).findViewById(R.id.popup_element)); popmW1 = new PopupWindow(vwLayout, PalmCalcActivity.inDispwidth, PalmCalcActivity.inDispheight, true); popmW1.setBackgroundDrawable(new BitmapDrawable()); popmW1.setOutsideTouchable(true);//from w w w.j av a 2 s. c om popmW1.showAtLocation(vwLayout, Gravity.CENTER, 0, 0); ImageButton btnCancel = (ImageButton) vwLayout.findViewById(R.id.butcancelmain); btnCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popmW1.dismiss(); } }); btns[0] = (Button) vwLayout.findViewById(R.id.btn1); btns[1] = (Button) vwLayout.findViewById(R.id.btn2); btns[2] = (Button) vwLayout.findViewById(R.id.btn3); btns[3] = (Button) vwLayout.findViewById(R.id.btn4); btns[4] = (Button) vwLayout.findViewById(R.id.btn5); btns[5] = (Button) vwLayout.findViewById(R.id.btn6); btns[6] = (Button) vwLayout.findViewById(R.id.btn7); btns[7] = (Button) vwLayout.findViewById(R.id.btn8); btns[8] = (Button) vwLayout.findViewById(R.id.btn9); for (int inI = 0; inI < 9; inI++) { btns[inI].setText(spMemory.getString("" + inI, "")); final int inK = inI; btns[inK].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mHandler.insert(btns[inK].getText().toString()); popmW1.dismiss(); } }); } }