List of usage examples for android.app Dialog setContentView
public void setContentView(@NonNull View view)
From source file:de.ub0r.android.websms.WebSMS.java
/** * Create a Emoticons {@link Dialog}.//from w w w . j a v a2s .c om * * @return Emoticons {@link Dialog} */ private Dialog createEmoticonsDialog() { final Dialog d = new Dialog(this); d.setTitle(R.string.emo_); d.setContentView(R.layout.emo); d.setCancelable(true); final String[] emoticons = this.getResources().getStringArray(R.array.emoticons); final GridView gridview = (GridView) d.findViewById(R.id.gridview); gridview.setAdapter(new BaseAdapter() { // references to our images // keep order and count synced with string-array! private Integer[] mThumbIds = { R.drawable.emo_im_angel, R.drawable.emo_im_cool, R.drawable.emo_im_crying, R.drawable.emo_im_foot_in_mouth, R.drawable.emo_im_happy, R.drawable.emo_im_kissing, R.drawable.emo_im_laughing, R.drawable.emo_im_lips_are_sealed, R.drawable.emo_im_money_mouth, R.drawable.emo_im_sad, R.drawable.emo_im_surprised, R.drawable.emo_im_tongue_sticking_out, R.drawable.emo_im_undecided, R.drawable.emo_im_winking, R.drawable.emo_im_wtf, R.drawable.emo_im_yelling }; @Override public long getItemId(final int position) { return 0; } @Override public Object getItem(final int position) { return null; } @Override public int getCount() { return this.mThumbIds.length; } @Override public View getView(final int position, final View convertView, final ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, // initialize some attributes imageView = new ImageView(WebSMS.this); imageView.setLayoutParams(new GridView.LayoutParams(EMOTICONS_SIZE, EMOTICONS_SIZE)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(EMOTICONS_PADDING, EMOTICONS_PADDING, EMOTICONS_PADDING, EMOTICONS_PADDING); } else { imageView = (ImageView) convertView; } imageView.setImageResource(this.mThumbIds[position]); return imageView; } }); gridview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapter, final View v, final int id, final long arg3) { EditText et = WebSMS.this.etText; final String e = emoticons[id]; int i = et.getSelectionStart(); int j = et.getSelectionEnd(); if (i > j) { int x = i; i = j; j = x; } String t = et.getText().toString(); et.setText(t.substring(0, i) + e + t.substring(j)); et.setSelection(i + e.length()); d.dismiss(); et.requestFocus(); } }); return d; }
From source file:com.fitme.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.options, menu); MenuItem mi = menu.findItem(R.id.menu_spinner_active_program); final TextView tv = (TextView) mi.getActionView(); ActiveProgramDAO apd = new ActiveProgramDAO(MainActivity.this); activeProgram = apd.getActiveProgramName(); tv.setText(activeProgram);//from w w w . j a va 2 s .c om tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { final Dialog dialog = new Dialog(MainActivity.this); dialog.setTitle(getText(R.string.title_select_prog_dialog)); View programView = getLayoutInflater().inflate(R.layout.programs_list, null); ExpandableListView elv = (ExpandableListView) programView.findViewById(R.id.list_programs); final ProgramListAdapter pda = new ProgramListAdapter(MainActivity.this); elv.setAdapter(pda); // Setting listener for Add Program button Button addProgram = (Button) programView.findViewById(R.id.button_add_program); addProgram.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { onAddProgramRequested(pda); } }); elv.setGroupIndicator(null); elv.setOnGroupClickListener(null); elv.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) { pda.setProgramSelected(groupPosition, childPosition); onNewProgramSelected(pda.getSelectedProgramName()); // Refresh trainings section list TrainingsSectionFragment tsf = (TrainingsSectionFragment) mAppSectionsPagerAdapter .getItem(AppSectionsPagerAdapter.SECTION_TRAININGS); tsf.onNewProgramSelected(); dialog.dismiss(); return false; } }); dialog.setContentView(programView); dialog.show(); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); } }); return true; }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
private void optionTutorial() { ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE); ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE); int userId = Util.getUserId(Process.myUid()); PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.FALSE.toString()); Dialog dlgUsage = new Dialog(this); dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON); dlgUsage.setTitle(R.string.title_usage_header); dlgUsage.setContentView(R.layout.usage); dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher)); dlgUsage.setCancelable(true);/* ww w . j a v a 2 s .c o m*/ dlgUsage.show(); }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
private void optionLegend() { // Show help/* w ww .java 2s .com*/ Dialog dialog = new Dialog(ActivityMain.this); dialog.requestWindowFeature(Window.FEATURE_LEFT_ICON); dialog.setTitle(R.string.menu_legend); dialog.setContentView(R.layout.legend); dialog.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher)); ((ImageView) dialog.findViewById(R.id.imgHelpHalf)).setImageBitmap(getHalfCheckBox()); ((ImageView) dialog.findViewById(R.id.imgHelpOnDemand)).setImageBitmap(getOnDemandCheckBox()); for (View child : Util.getViewsByTag((ViewGroup) dialog.findViewById(android.R.id.content), "details")) child.setVisibility(View.GONE); ((LinearLayout) dialog.findViewById(R.id.llUnsafe)) .setVisibility(PrivacyManager.cVersion3 ? View.VISIBLE : View.GONE); dialog.setCancelable(true); dialog.show(); }
From source file:com.updetector.MainActivity.java
/** * Handle Performance Tuning Click//w w w . j a va2s. c o m */ private void handleAdvancedSetting() { final Dialog dialog = new Dialog(this); dialog.setTitle(R.string.menu_item_advanced_settings); dialog.setContentView(R.layout.advanced_setting); final SharedPreferences mPrefs = getSharedPreferences(Constants.SHARED_PREFERENCES, Context.MODE_PRIVATE); final Editor editor = mPrefs.edit(); final ToggleButton classifierForCIVOnButton = (ToggleButton) dialog.findViewById(R.id.civ_classifier_on); classifierForCIVOnButton.setChecked(mPrefs.getBoolean(Constants.PREFERENCE_KEY_CIV_CLASSIFIER_ON, false)); final ToggleButton isOutdoorButton = (ToggleButton) dialog.findViewById(R.id.is_outdoor); isOutdoorButton.setChecked(mPrefs.getBoolean(Constants.PREFERENCE_KEY_IS_OUTDOOR, false)); final EditText notificationTresholdText = (EditText) dialog.findViewById(R.id.notification_threshold); notificationTresholdText .setText(String.format("%.2f", mPrefs.getFloat(Constants.PREFERENCE_KEY_NOTIFICATION_THRESHOLD, (float) Constants.DEFAULT_DETECTION_THRESHOLD))); //final EditText detectionIntervalText=(EditText)dialog.findViewById(R.id.detection_interval); //detectionIntervalText.setText(String.valueOf(mPrefs.getInt(Constants.PREFERENCE_KEY_DETECTION_INTERVAL, Constants.DETECTION_INTERVAL_DEFAULT_VALUE) )); final EditText googleActivityUpdateIntervalText = (EditText) dialog .findViewById(R.id.google_activity_update_interval); googleActivityUpdateIntervalText .setText(String.valueOf(mPrefs.getInt(Constants.PREFERENCE_KEY_GOOGLE_ACTIVITY_UPDATE_INTERVAL, Constants.GOOGLE_ACTIVITY_UPDATE_INTERVAL_DEFAULT_VALUE))); //final ToggleButton useGoogleActivityInFusion=(ToggleButton)dialog.findViewById(R.id.use_google_for_motion_state_in_fusion); //useGoogleActivityInFusion.setChecked(mPrefs.getBoolean(Constants.PREFERENCE_KEY_USE_GOOGLE_ACTIVITY_IN_FUSION, false)); final ToggleButton logAcclRawButton = (ToggleButton) dialog.findViewById(R.id.log_raw_switch); logAcclRawButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_ACCL_RAW_SWITCH, false)); final ToggleButton logGoogleActUpdatesButton = (ToggleButton) dialog .findViewById(R.id.log_google_updates_switch); logGoogleActUpdatesButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_GOOGLE_ACTIVITY_UPDATE, false)); final ToggleButton logDetectionButton = (ToggleButton) dialog.findViewById(R.id.log_report_switch); logDetectionButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_DETECTION_SWITCH, false)); final ToggleButton logErrorButton = (ToggleButton) dialog.findViewById(R.id.log_error_switch); logErrorButton.setChecked(mPrefs.getBoolean(Constants.LOGGING_ERROR_SWITCH, true)); //final EditText deltaForConditionalProb=(EditText)dialog.findViewById(R.id.normal_dist_delta); //deltaForConditionalProb.setText(String.valueOf(mPrefs.getFloat(Constants.CIV_DELTA_CONDITIONAL_PROBABILITY, 2)) ); final Button applyButton = (Button) dialog.findViewById(R.id.performance_apply_button); final Button cancelButton = (Button) dialog.findViewById(R.id.peformance_cancel_button); applyButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (classifierForCIVOnButton.isChecked()) editor.putBoolean(Constants.PREFERENCE_KEY_CIV_CLASSIFIER_ON, true); else editor.putBoolean(Constants.PREFERENCE_KEY_CIV_CLASSIFIER_ON, false); if (isOutdoorButton.isChecked()) editor.putBoolean(Constants.PREFERENCE_KEY_IS_OUTDOOR, true); else editor.putBoolean(Constants.PREFERENCE_KEY_IS_OUTDOOR, false); if (logAcclRawButton.isChecked()) editor.putBoolean(Constants.LOGGING_ACCL_RAW_SWITCH, true); else editor.putBoolean(Constants.LOGGING_ACCL_RAW_SWITCH, false); if (logGoogleActUpdatesButton.isChecked()) editor.putBoolean(Constants.LOGGING_GOOGLE_ACTIVITY_UPDATE, true); else editor.putBoolean(Constants.LOGGING_GOOGLE_ACTIVITY_UPDATE, false); if (logDetectionButton.isChecked()) editor.putBoolean(Constants.LOGGING_DETECTION_SWITCH, true); else editor.putBoolean(Constants.LOGGING_DETECTION_SWITCH, false); if (logErrorButton.isChecked()) editor.putBoolean(Constants.LOGGING_ERROR_SWITCH, true); else editor.putBoolean(Constants.LOGGING_ERROR_SWITCH, false); float notificationTreshold; try { notificationTreshold = Float.parseFloat(notificationTresholdText.getText().toString()); } catch (Exception ex) { notificationTreshold = (float) Constants.DEFAULT_DETECTION_THRESHOLD; } editor.putFloat(Constants.PREFERENCE_KEY_NOTIFICATION_THRESHOLD, notificationTreshold); /*int detectionInterval; try{ detectionInterval=Integer.parseInt( detectionIntervalText.getText().toString()); }catch(Exception ex){ detectionInterval=Constants.DETECTION_INTERVAL_DEFAULT_VALUE; } editor.putInt(Constants.PREFERENCE_KEY_DETECTION_INTERVAL, detectionInterval);*/ /*if (useGoogleActivityInFusion.isChecked()) editor.putBoolean(Constants.PREFERENCE_KEY_USE_GOOGLE_ACTIVITY_IN_FUSION, true); else editor.putBoolean(Constants.PREFERENCE_KEY_USE_GOOGLE_ACTIVITY_IN_FUSION, false);*/ int googleActivityUpdateInterval; try { googleActivityUpdateInterval = Integer .parseInt(googleActivityUpdateIntervalText.getText().toString()); } catch (Exception ex) { googleActivityUpdateInterval = Constants.GOOGLE_ACTIVITY_UPDATE_INTERVAL_DEFAULT_VALUE; } editor.putInt(Constants.PREFERENCE_KEY_GOOGLE_ACTIVITY_UPDATE_INTERVAL, googleActivityUpdateInterval); /*try{ Float delta=Float.parseFloat(deltaForConditionalProb.getText().toString()); editor.putFloat(Constants.CIV_DELTA_CONDITIONAL_PROBABILITY, delta); }catch(Exception ex){ Toast.makeText(getApplicationContext(), "Input must be a float number", Toast.LENGTH_SHORT).show(); }*/ editor.commit(); dialog.cancel(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { dialog.cancel(); } }); dialog.show(); }
From source file:org.fox.ttrss.OnlineActivity.java
@Override public boolean onContextItemSelected(android.view.MenuItem item) { /* AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo(); *///from w ww .ja v a 2 s .c o m final ArticlePager ap = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE); switch (item.getItemId()) { case R.id.article_img_open: if (getLastContentImageHitTestUrl() != null) { try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getLastContentImageHitTestUrl())); startActivity(intent); } catch (Exception e) { e.printStackTrace(); toast(R.string.error_other_error); } } return true; case R.id.article_img_copy: if (getLastContentImageHitTestUrl() != null) { copyToClipboard(getLastContentImageHitTestUrl()); } return true; case R.id.article_img_share: if (getLastContentImageHitTestUrl() != null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/png"); intent.putExtra(Intent.EXTRA_SUBJECT, getLastContentImageHitTestUrl()); intent.putExtra(Intent.EXTRA_TEXT, getLastContentImageHitTestUrl()); startActivity(Intent.createChooser(intent, getLastContentImageHitTestUrl())); } return true; case R.id.article_img_view_caption: if (getLastContentImageHitTestUrl() != null) { // Android doesn't give us an easy way to access title tags; // we'll use Jsoup on the body text to grab the title text // from the first image tag with this url. This will show // the wrong text if an image is used multiple times. Document doc = Jsoup.parse(ap.getSelectedArticle().content); Elements es = doc.getElementsByAttributeValue("src", getLastContentImageHitTestUrl()); if (es.size() > 0) { if (es.get(0).hasAttr("title")) { Dialog dia = new Dialog(this); if (es.get(0).hasAttr("alt")) { dia.setTitle(es.get(0).attr("alt")); } else { dia.setTitle(es.get(0).attr("title")); } TextView titleText = new TextView(this); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { titleText.setPaddingRelative(24, 24, 24, 24); } else { titleText.setPadding(24, 24, 24, 24); } titleText.setTextSize(16); titleText.setText(es.get(0).attr("title")); dia.setContentView(titleText); dia.show(); } else { toast(R.string.no_caption_to_display); } } else { toast(R.string.no_caption_to_display); } } return true; case R.id.article_link_share: if (ap != null && ap.getSelectedArticle() != null) { shareArticle(ap.getSelectedArticle()); } return true; case R.id.article_link_copy: Log.d(TAG, "article_link_copy"); if (ap != null && ap.getSelectedArticle() != null) { copyToClipboard(ap.getSelectedArticle().link); } return true; default: Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId()); return super.onContextItemSelected(item); } }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
@SuppressLint("DefaultLocale") private void optionAbout() { // About//from w w w. j a va2 s . com Dialog dlgAbout = new Dialog(this); dlgAbout.requestWindowFeature(Window.FEATURE_LEFT_ICON); dlgAbout.setTitle(R.string.menu_about); dlgAbout.setContentView(R.layout.about); dlgAbout.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher)); // Show version try { int userId = Util.getUserId(Process.myUid()); Version currentVersion = new Version(Util.getSelfVersionName(this)); Version storedVersion = new Version( PrivacyManager.getSetting(userId, PrivacyManager.cSettingVersion, "0.0")); boolean migrated = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingMigrated, false); String versionName = currentVersion.toString(); if (currentVersion.compareTo(storedVersion) != 0) versionName += "/" + storedVersion.toString(); if (!migrated) versionName += "!"; int versionCode = Util.getSelfVersionCode(this); TextView tvVersion = (TextView) dlgAbout.findViewById(R.id.tvVersion); tvVersion.setText(String.format(getString(R.string.app_version), versionName, versionCode)); } catch (Throwable ex) { Util.bug(null, ex); } if (!PrivacyManager.cVersion3 || Hook.isAOSP(19)) ((TextView) dlgAbout.findViewById(R.id.tvCompatibility)).setVisibility(View.GONE); // Show license String licensed = Util.hasProLicense(this); TextView tvLicensed1 = (TextView) dlgAbout.findViewById(R.id.tvLicensed); TextView tvLicensed2 = (TextView) dlgAbout.findViewById(R.id.tvLicensedAlt); if (licensed == null) { tvLicensed1.setText(Environment.getExternalStorageDirectory().getAbsolutePath()); tvLicensed2.setText(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) .getAbsolutePath()); } else { tvLicensed1.setText(String.format(getString(R.string.app_licensed), licensed)); tvLicensed2.setVisibility(View.GONE); } // Show some build properties String android = String.format("%s (%d)", Build.VERSION.RELEASE, Build.VERSION.SDK_INT); ((TextView) dlgAbout.findViewById(R.id.tvAndroid)).setText(android); ((TextView) dlgAbout.findViewById(R.id.build_brand)).setText(Build.BRAND); ((TextView) dlgAbout.findViewById(R.id.build_manufacturer)).setText(Build.MANUFACTURER); ((TextView) dlgAbout.findViewById(R.id.build_model)).setText(Build.MODEL); ((TextView) dlgAbout.findViewById(R.id.build_product)).setText(Build.PRODUCT); ((TextView) dlgAbout.findViewById(R.id.build_device)).setText(Build.DEVICE); ((TextView) dlgAbout.findViewById(R.id.build_host)).setText(Build.HOST); ((TextView) dlgAbout.findViewById(R.id.build_display)).setText(Build.DISPLAY); ((TextView) dlgAbout.findViewById(R.id.build_id)).setText(Build.ID); dlgAbout.setCancelable(true); final int userId = Util.getUserId(Process.myUid()); if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFirstRun, true)) dlgAbout.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { Dialog dlgUsage = new Dialog(ActivityMain.this); dlgUsage.requestWindowFeature(Window.FEATURE_LEFT_ICON); dlgUsage.setTitle(R.string.app_name); dlgUsage.setContentView(R.layout.usage); dlgUsage.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, getThemed(R.attr.icon_launcher)); dlgUsage.setCancelable(true); dlgUsage.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { PrivacyManager.setSetting(userId, PrivacyManager.cSettingFirstRun, Boolean.FALSE.toString()); optionLegend(); } }); dlgUsage.show(); } }); dlgAbout.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
private void confirmSendLog() { mGlblParms.util.flushLog();// w ww. j a v a 2 s. c o m createTempLogFile(); final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_send_log_dlg); final Button btn_ok = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_cancel_btn); final Button btn_preview = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_preview); CommonDialog.setDlgBoxSizeLimit(dialog, false); btn_preview.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + mEnvParms.settingLogMsgDir + "temp_log.txt"), "text/plain"); startActivity(intent); } }); btn_ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mGlblParms.util.sendLogFileToDeveloper(mEnvParms.settingLogMsgDir + "temp_log.txt"); dialog.dismiss(); } }); btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
@SuppressLint("NewApi") final private void aboutTaskAutomation() { // common ??/*from www. j a v a 2 s . c o m*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.about_dialog); ((TextView) dialog.findViewById(R.id.about_dialog_title)) .setText(getString(R.string.msgs_about_dlg_title) + " Ver " + getApplVersionName()); final WebView func_view = (WebView) dialog.findViewById(R.id.about_dialog_function); // func_view.setWebViewClient(new WebViewClient()); // func_view.getSettings().setJavaScriptEnabled(true); func_view.getSettings().setSupportZoom(true); // func_view.setVerticalScrollbarOverlay(true); func_view.setBackgroundColor(Color.LTGRAY); // func_view.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET); func_view.setVerticalScrollBarEnabled(true); func_view.setScrollbarFadingEnabled(false); if (Build.VERSION.SDK_INT > 10) { func_view.getSettings().setDisplayZoomControls(true); func_view.getSettings().setBuiltInZoomControls(true); } else { func_view.getSettings().setBuiltInZoomControls(true); } func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_about_dlg_func_html)); final WebView change_view = (WebView) dialog.findViewById(R.id.about_dialog_change_history); if (Build.VERSION.SDK_INT > 10) { func_view.getSettings().setDisplayZoomControls(true); func_view.getSettings().setBuiltInZoomControls(true); } else { func_view.getSettings().setBuiltInZoomControls(true); } change_view.loadDataWithBaseURL("file:///android_asset/", getString(R.string.msgs_about_dlg_change_desc), "text/html", "UTF-8", ""); change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); change_view.getSettings().setSupportZoom(true); if (Build.VERSION.SDK_INT > 10) { change_view.getSettings().setDisplayZoomControls(true); change_view.getSettings().setBuiltInZoomControls(true); } else { change_view.getSettings().setBuiltInZoomControls(true); } final Button btnFunc = (Button) dialog.findViewById(R.id.about_dialog_btn_show_func); final Button btnChange = (Button) dialog.findViewById(R.id.about_dialog_btn_show_change); final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok); func_view.setVisibility(TextView.VISIBLE); change_view.setVisibility(TextView.GONE); btnChange.setBackgroundResource(R.drawable.button_back_ground_color_selector); btnFunc.setBackgroundResource(R.drawable.button_back_ground_color_selector); btnChange.setTextColor(Color.DKGRAY); btnFunc.setTextColor(Color.GREEN); btnFunc.setEnabled(false); CommonDialog.setDlgBoxSizeLimit(dialog, true); // func? btnFunc.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.GONE); func_view.setVisibility(TextView.VISIBLE); CommonDialog.setDlgBoxSizeLimit(dialog, true); btnFunc.setTextColor(Color.GREEN); btnChange.setTextColor(Color.DKGRAY); btnChange.setEnabled(true); btnFunc.setEnabled(false); } }); // change? btnChange.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { change_view.setVisibility(TextView.VISIBLE); func_view.setVisibility(TextView.GONE); CommonDialog.setDlgBoxSizeLimit(dialog, true); btnChange.setTextColor(Color.GREEN); btnFunc.setTextColor(Color.DKGRAY); btnChange.setEnabled(false); btnFunc.setEnabled(true); } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnOk.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:xj.property.activity.HXBaseActivity.MainActivity.java
/** * ??dialog/*from w w w . j av a2 s .c o m*/ */ private void showConflictDialog() { isConflictDialogShow = true; final UserInfoDetailBean detailBean = PreferencesUtil.getLoginInfo(getApplication()); username = detailBean.getUsername(); password = detailBean.getPassword(); final XJUserInfoBean bean = new XJUserInfoBean(); bean.setInfo(detailBean); if (xjpushManager != null) { xjpushManager.unregisterLoginedPushService(); } else { xjpushManager = new XJPushManager(this); xjpushManager.unregisterLoginedPushService(); } // boolean flag= PushManager.getInstance().unBindAlias(MainActivity.this, PreferencesUtil.getLoginInfo(MainActivity.this).getEmobId()); // Log.i("onion","flag"+flag); XjApplication.getInstance().logout(new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { @Override public void run() { refreshUI(); refreshNewBangBiUI(); } }); } @Override public void onError(int i, String s) { } @Override public void onProgress(int i, String s) { } }); PreferencesUtil.Logout(MainActivity.this); if (!MainActivity.this.isFinishing()) { // clear up global variables try { final Dialog dialog = new Dialog(MainActivity.this, R.style.MyDialogStyle); dialog.setContentView(R.layout.dialog_conflict); TextView tv_cancle = (TextView) dialog.findViewById(R.id.tv_cancle); TextView tv_relogin = (TextView) dialog.findViewById(R.id.tv_relogin); tv_cancle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { conflictBuilder = null; dialog.dismiss(); index = 0; updateUnreadLabel(); startActivity(new Intent(MainActivity.this, MainActivity.class)); // finish(); } }); tv_relogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final ProgressDialog pd = new ProgressDialog(MainActivity.this, ProgressDialog.THEME_HOLO_LIGHT); pd.setCanceledOnTouchOutside(false); pd.setCancelable(false); pd.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); progressShow = true; pd.setMessage("..."); if (pd != null && !MainActivity.this.isFinishing()) pd.show(); //??? // getuser((int) detailBean.getCommunityId(),detailBean.getEmobId()); UserUtils.reLoginUser(MainActivity.this, username, password, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case Config.LoginUserComplete: if (progressShow) pd.dismiss(); dialog.dismiss(); startActivity(new Intent(MainActivity.this, MainActivity.class)); isConflict = false; // boolean flag = PushManager.getInstance().bindAlias(MainActivity.this, PreferencesUtil.getLoginInfo(MainActivity.this).getEmobId()); PushManager.getInstance().turnOnPush(MainActivity.this); if (xjpushManager == null) { xjpushManager = new XJPushManager(getmContext()); } xjpushManager.registerLoginedPushService(); break; case Config.LoginUserFailure: if (progressShow && !MainActivity.this.isFinishing()) { pd.dismiss(); Toast.makeText(MainActivity.this, "?", Toast.LENGTH_SHORT) .show(); } break; default: pd.setMessage(".."); break; } } }); /* UserUtils.loginEMChat(MainActivity.this, username, bean, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case Config.LoginUserComplete: if (progressShow) pd.dismiss(); dialog.dismiss(); UserUtils.appLogin(MainActivity.this,PushManager.getInstance().getClientid(MainActivity.this), PreferencesUtil.getLoginInfo(MainActivity.this).getUsername()); startActivity(new Intent(MainActivity.this, MainActivity.class)); isConflict=false; boolean flag= PushManager.getInstance().bindAlias(MainActivity.this, PreferencesUtil.getLoginInfo(MainActivity.this).getEmobId()); PushManager.getInstance().turnOnPush(MainActivity.this); break; case Config.LoginUserFailure: if (progressShow && !MainActivity.this.isFinishing()) { pd.dismiss(); Toast.makeText(MainActivity.this, "?", Toast.LENGTH_SHORT).show(); } break; default: pd.setMessage(".."); break; } } });*/ } }); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0)); dialog.setCancelable(false); dialog.show(); isConflict = true; } catch (Exception e) { EMLog.e(TAG, "---------color conflictBuilder error" + e.getMessage()); } } }