List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.quwu.xinwo.release.Release_Activity.java
private void findID() { release_saveBtn = (Button) findViewById(R.id.release_saveBtn); release_saveBtn.setOnClickListener(this); pd = new CustomProgressDialog2(Release_Activity.this, R.style.dialog); pd.setCancelable(false);//from w w w. j a va 2 s . co m layout = (LinearLayout) findViewById(R.id.releaseLin); release_cordelesBoxLin = (LinearLayout) findViewById(R.id.release_cordelesBoxLin); release_auctionBoxLin = (LinearLayout) findViewById(R.id.release_auctionBoxLin); release_rent_outBoxLin = (LinearLayout) findViewById(R.id.release_rent_outBoxLin); release_freeBoxLin = (LinearLayout) findViewById(R.id.release_freeBoxLin); release_cordelesBoxLin.setOnClickListener(this); release_auctionBoxLin.setOnClickListener(this); release_rent_outBoxLin.setOnClickListener(this); release_freeBoxLin.setOnClickListener(this); release_cordeles_Box1Lin = (LinearLayout) findViewById(R.id.release_cordeles_Box1Lin); release_cordeles_Box2Lin = (LinearLayout) findViewById(R.id.release_cordeles_Box2Lin); release_cordeles_Box1Lin.setOnClickListener(this); release_cordeles_Box2Lin.setOnClickListener(this); release_label_box1 = (CheckBox) findViewById(R.id.release_label_box1); release_label_box2 = (CheckBox) findViewById(R.id.release_label_box2); release_label_box3 = (CheckBox) findViewById(R.id.release_label_box3); release_label_box4 = (CheckBox) findViewById(R.id.release_label_box4); release_label_box5 = (CheckBox) findViewById(R.id.release_label_box5); release_label_box6 = (CheckBox) findViewById(R.id.release_label_box6); release_label_box7 = (CheckBox) findViewById(R.id.release_label_box7); release_free_checkboxLin_box1 = (CheckBox) findViewById(R.id.release_free_checkboxLin_box1); release_free_checkboxLin_box2 = (CheckBox) findViewById(R.id.release_free_checkboxLin_box2); release_confirmBtn = (Button) findViewById(R.id.release_confirmBtn); release_confirmBtn.setOnClickListener(this); releaseLin = (LinearLayout) findViewById(R.id.releaseLin); keyboardView = (KeyboardView) findViewById(R.id.keyboard_view); gridView = (MyGridView) findViewById(R.id.release_gridview); checkBox = (LinearLayout) findViewById(R.id.release_checkBox); free_checkboxLin = (LinearLayout) findViewById(R.id.release_free_checkboxLin); titleEd = (EditText) findViewById(R.id.release_titleEd); describeEd = (EditText) findViewById(R.id.release_decribeEd); InputFilterSpace.inputFilterSpace(titleEd, 20); InputFilterSpace.inputFilterSpace(describeEd, 50); playerBtn = (Button) findViewById(R.id.release_pleyerBtn); playerBtn.setOnClickListener(this); areaBtn = (Button) findViewById(R.id.release_areaBtn); cordelesBox = (CheckBox) findViewById(R.id.release_cordelesBox); auctionBox = (CheckBox) findViewById(R.id.release_auctionBox); rent_outBox = (CheckBox) findViewById(R.id.release_rent_outBox); freeBox = (CheckBox) findViewById(R.id.release_freeBox); classifyLin = (LinearLayout) findViewById(R.id.release_classifyLin); classifyText = (TextView) findViewById(R.id.release_classifyText); classifyLin.setOnClickListener(this); cordelesLin = (LinearLayout) findViewById(R.id.release_cordelesLin); auctionLin = (LinearLayout) findViewById(R.id.release_auctionLin); rent_outLin = (LinearLayout) findViewById(R.id.release_rent_outLin); freeLin = (LinearLayout) findViewById(R.id.release_freeLin); selling_priceEd = (EditText) findViewById(R.id.release_cordeles_selling_priceEd); cordelesBox1 = (CheckBox) findViewById(R.id.release_cordeles_Box1); cordelesBox2 = (CheckBox) findViewById(R.id.release_cordeles_Box2); cordeles_questionImage = (ImageView) findViewById(R.id.release_cordeles_questionIamge); cordeles_questionImage.setOnClickListener(this); selling_priceEd.setOnTouchListener(new MyTouchListener(selling_priceEd, "1")); auction_startPriceEd = (EditText) findViewById(R.id.release_auction_startPriceEd); auction_retainPriceEd = (EditText) findViewById(R.id.release_auction_retainPriceEd); auction_rangeEd = (EditText) findViewById(R.id.release_auction_rangeEd); auction_cash_depositEd = (EditText) findViewById(R.id.release_auction_cash_depositEd); auction_questionImage = (ImageView) findViewById(R.id.release_auction_questionImage); auction_questionImage.setOnClickListener(this); auction_retainPriceEd.setOnTouchListener(new MyTouchListener(auction_retainPriceEd, "2")); isKeyBoard(auction_startPriceEd); isKeyBoard(auction_rangeEd); isKeyBoard(auction_cash_depositEd); /** * * */ auction_rangeEd.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s != null) { } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); rent_out_valueEd = (EditText) findViewById(R.id.release_rent_out_valueEd); rent_out_freightEd = (EditText) findViewById(R.id.release_rent_out_freightEd); rent_out_rentEd = (EditText) findViewById(R.id.release_rent_out_rentEd); rent_out_tenancy_termEd = (EditText) findViewById(R.id.release_rent_out_tenancy_termEd); rent_out_rentImage = (ImageView) findViewById(R.id.release_rent_out_rentImage); release_rent_out_rent_yearText = (TextView) findViewById(R.id.release_rent_out_rent_yearText); release_rent_out_tenancy_term_yearText = (TextView) findViewById( R.id.release_rent_out_tenancy_term_yearText); rent_out_rentImage.setOnClickListener(this); release_rent_out_rent_yearText.setOnClickListener(this); release_rent_out_tenancy_term_yearText.setOnClickListener(this); rent_out_valueEd.setOnTouchListener(new MyTouchListener(rent_out_valueEd, "3")); rent_out_freightEd.setOnTouchListener(new MyTouchListener(rent_out_freightEd, "3")); isKeyBoard(rent_out_rentEd); isKeyBoard(rent_out_tenancy_termEd); free_freightEd = (EditText) findViewById(R.id.release_free_freightEd); free_QQEd = (EditText) findViewById(R.id.release_free_QQEd); isKeyBoard(free_freightEd); isKeyBoard(free_QQEd); }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
public void setUpSimilar() { attachImage[0] = (ImageView) findViewById(R.id.picture1); attachImage[1] = (ImageView) findViewById(R.id.picture2); attachImage[2] = (ImageView) findViewById(R.id.picture3); attachImage[3] = (ImageView) findViewById(R.id.picture4); attachButton = (ImageButton) findViewById(R.id.attach); emojiButton = (ImageButton) findViewById(R.id.emoji); emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emojiKeyboard); reply = (EditText) findViewById(R.id.tweet_content); charRemaining = (TextView) findViewById(R.id.char_remaining); findViewById(R.id.prompt_pos).setOnClickListener(new View.OnClickListener() { @Override//from w ww.j av a 2 s . co m public void onClick(View v) { Log.v("Test_input", "clicked the view"); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(reply, InputMethodManager.SHOW_FORCED); } }); NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic); HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name); if (settings.roundContactImages) { pic.loadImage(settings.myProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE); } else { pic.loadImage(settings.myProfilePicUrl, false, null); } currentName.setText("@" + settings.myScreenName); //numberAttached.setText("0 " + getString(R.string.attached_images)); charRemaining.setText(140 - reply.getText().length() + ""); reply.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { countHandler.removeCallbacks(getCount); countHandler.postDelayed(getCount, 300); } }); }
From source file:cn.yunluosoft.tonglou.activity.ChatActivity.java
/** * initView/* w w w . j a v a2 s . c o m*/ */ protected void initView() { recordingContainer = findViewById(R.id.recording_container); back = (ImageView) findViewById(R.id.title_back); // icon = (CircleImageView) findViewById(R.id.title_image); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call); videoCallBtn = (ImageView) findViewById(R.id.btn_video_call); // ?, micImages = new Drawable[] { getResources().getDrawable(R.mipmap.record_animate_01), getResources().getDrawable(R.mipmap.record_animate_02), getResources().getDrawable(R.mipmap.record_animate_03), getResources().getDrawable(R.mipmap.record_animate_04), getResources().getDrawable(R.mipmap.record_animate_05), getResources().getDrawable(R.mipmap.record_animate_06), getResources().getDrawable(R.mipmap.record_animate_07), getResources().getDrawable(R.mipmap.record_animate_08), getResources().getDrawable(R.mipmap.record_animate_09), getResources().getDrawable(R.mipmap.record_animate_10), getResources().getDrawable(R.mipmap.record_animate_11), getResources().getDrawable(R.mipmap.record_animate_12), getResources().getDrawable(R.mipmap.record_animate_13), getResources().getDrawable(R.mipmap.record_animate_14) }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:com.efithealth.app.activity.ChatActivity.java
/** * initView//from w w w . j a v a2s . c o m */ protected void initView() { panel_root = (KPSwitchFSPanelLinearLayout) findViewById(R.id.panel_root); //? ogll = new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); WindowManager wm = getWindowManager(); height = wm.getDefaultDisplay().getHeight(); int h = height - (rect.bottom - rect.top); boolean flag123 = h > height / 3; if (flag123) { panel_root.setVisibility(View.VISIBLE); } else { panel_root.setVisibility(View.GONE); } } }; recordingContainer = findViewById(R.id.recording_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call); videoCallBtn = (ImageView) findViewById(R.id.btn_video_call); findViewById(R.id.container_voice_call).setVisibility(View.GONE); findViewById(R.id.container_video_call).setVisibility(View.GONE); findViewById(R.id.container_file).setVisibility(View.GONE); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14) }; // list reslist = getExpressionRes(35); // ?viewpager List<View> views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); views.add(gv1); views.add(gv2); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //?? getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(ogll); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); swipeRefreshLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:com.nice295.scratchgames.fragment.MygamesFragment.java
private void showAddDialog() { AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.DialogTheme); LayoutInflater inflater = getActivity().getLayoutInflater(); final View dialogView = inflater.inflate(R.layout.dialog_add, null); dialogBuilder.setView(dialogView);/*from w w w . j av a2 s . c om*/ final EditText editId = (EditText) dialogView.findViewById(R.id.editId); final EditText editName = (EditText) dialogView.findViewById(R.id.editName); final EditText editUser = (EditText) dialogView.findViewById(R.id.editUser); dialogBuilder.setTitle(getString(R.string.add_you_game_title)); dialogBuilder.setMessage(getString(R.string.add_you_game_message)); dialogBuilder.setPositiveButton(getString(R.string.add), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (editId.getText() != null && editName.getText() != null && editUser.getText() != null) { addNewMyItem(editId.getText().toString(), editName.getText().toString(), editUser.getText().toString(), "https://cdn2.scratch.mit.edu/get_image/project/" + editId.getText() + "_282x210.png"); addNewMyItemExt(editId.getText().toString()); editId.clearFocus(); editId.setText(""); editName.clearFocus(); editName.setText(""); editUser.clearFocus(); editUser.setText(""); getActivity().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); Toast.makeText(getActivity(), getString(R.string.added_your_game), Toast.LENGTH_SHORT).show(); } else { Log.e(TAG, "Input Text!"); } } }); dialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); final AlertDialog b = dialogBuilder.create(); b.show(); // Initially disable the button ((AlertDialog) b).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); // Now set the textchange listener for edittext editName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { // Check if edittext is empty if (editId.getText().length() != 9 || TextUtils.getTrimmedLength(s) < 3) { // Disable ok button ((AlertDialog) b).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } else { // Something into edit text. Enable the button. ((AlertDialog) b).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); } } }); // Now set the textchange listener for edittext editId.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { // Check if edittext is empty if (editName.getText().length() < 3 || TextUtils.getTrimmedLength(s) != 9) { // Disable ok button ((AlertDialog) b).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } else { // Something into edit text. Enable the button. ((AlertDialog) b).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); } } }); }
From source file:com.brewcrewfoo.performance.fragments.Advanced.java
public void openDialog(String title, final int min, final int max, final Preference pref, final String path, final String key) { Resources res = context.getResources(); String cancel = res.getString(R.string.cancel); String ok = res.getString(R.string.ok); final EditText settingText; LayoutInflater factory = LayoutInflater.from(context); final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null); final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar); seekbar.setMax(max - min);// w ww. j ava2s .c o m int currentProgress = min; if (key.equals("pref_viber")) { currentProgress = Integer.parseInt(vib.get_val(path)); } else { currentProgress = Integer.parseInt(Helpers.readOneLine(path)); } if (currentProgress > max) currentProgress = max - min; else if (currentProgress < min) currentProgress = 0; else currentProgress = currentProgress - min; seekbar.setProgress(currentProgress); settingText = (EditText) alphaDialog.findViewById(R.id.setting_text); settingText.setText(Integer.toString(currentProgress + min)); settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { int val = Integer.parseInt(settingText.getText().toString()) - min; seekbar.setProgress(val); return true; } return false; } }); settingText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { int val = Integer.parseInt(s.toString()); if (val > max) { s.replace(0, s.length(), Integer.toString(max)); val = max; } seekbar.setProgress(val - min); } catch (NumberFormatException ex) { } } }); OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { final int mSeekbarProgress = seekbar.getProgress(); if (fromUser) { settingText.setText(Integer.toString(mSeekbarProgress + min)); } } @Override public void onStopTrackingTouch(SeekBar seekbar) { } @Override public void onStartTrackingTouch(SeekBar seekbar) { } }; seekbar.setOnSeekBarChangeListener(seekBarChangeListener); new AlertDialog.Builder(context).setTitle(title).setView(alphaDialog) .setNegativeButton(cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // nothing } }).setPositiveButton(ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int val = min; if (!settingText.getText().toString().equals("")) val = Integer.parseInt(settingText.getText().toString()); if (val < min) val = min; seekbar.setProgress(val - min); int newProgress = seekbar.getProgress() + min; new CMDProcessor().su .runWaitFor("busybox echo " + Integer.toString(newProgress) + " > " + path); String v; if (key.equals("pref_viber")) { v = vib.get_val(path); Vibrator vb = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vb.vibrate(1000); } else { v = Helpers.readOneLine(path); } final SharedPreferences.Editor editor = mPreferences.edit(); editor.putInt(key, Integer.parseInt(v)).commit(); pref.setSummary(v); } }).create().show(); }
From source file:com.digitalarx.android.authentication.AuthenticatorActivity.java
/** * //ww w .j a va 2 s .c o m * @param savedInstanceState Saved activity state, as in {{@link #onCreate(Bundle)} */ private void initServerPreFragment(Bundle savedInstanceState) { /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState) boolean isUrlInputAllowed = getResources().getBoolean(R.bool.show_server_url_input); if (savedInstanceState == null) { if (mAccount != null) { mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); // TODO do this in a setter for mBaseUrl String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); if (ocVersion != null) { mServerInfo.mVersion = new OwnCloudVersion(ocVersion); } } else { mServerInfo.mBaseUrl = getString(R.string.server_url).trim(); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); } } else { mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); // TODO parcelable mServerInfo.mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mServerInfo.mBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mServerInfo.mVersion = new OwnCloudVersion(ocVersion); } mServerInfo.mAuthMethod = AuthenticationMethod .valueOf(savedInstanceState.getString(KEY_SERVER_AUTH_METHOD)); } /// step 2 - set properties of UI elements (text, visibility, enabled...) mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mHostUrlInput.setText(mServerInfo.mBaseUrl); if (mAction != ACTION_CREATE) { /// lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); } if (isUrlInputAllowed) { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } else { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } showRefreshButton(mServerIsChecked && !mServerIsValid && mWaitingForOpId > Integer.MAX_VALUE); mServerStatusView = (TextView) findViewById(R.id.server_status_text); showServerStatus(); /// step 3 - bind some listeners and options mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); /// step 4 - create listeners that will be bound at onResume mHostUrlInputWatcher = new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (mOkButton.isEnabled() && !mServerInfo.mBaseUrl.equals(normalizeUrl(s.toString(), mServerInfo.mIsSslConn))) { mOkButton.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mAuthStatusIcon != 0) { Log_OC.d(TAG, "onTextChanged: hiding authentication status"); mAuthStatusIcon = 0; mAuthStatusText = 0; showAuthStatus(); } } }; // TODO find out if this is really necessary, or if it can done in a different way findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()) .equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); /// step 4 - mark automatic check to be started when OperationsService is ready mPendingAutoCheck = (savedInstanceState == null && (mAction != ACTION_CREATE || !isUrlInputAllowed)); }
From source file:com.bai.android.ui.OtherActivity.java
public void callSettings() { versionTextView = (TextView) findViewById(R.id.version); try {// ww w. ja v a 2s . co m versionName = getApplicationContext().getPackageManager() .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } versionTextView.setText(versionName); logoutButton = (Button) findViewById(R.id.logout_button); logoutButton.setOnClickListener(this); changePWButton = (Button) findViewById(R.id.change_pw_button); changePWButton.setOnClickListener(this); changeSoundButton = (Button) findViewById(R.id.change_sound_button); changeSoundButton.setOnClickListener(this); oldPWEditText = (EditText) findViewById(R.id.old_pw_edit); newPWEditText = (EditText) findViewById(R.id.new_pw_edit); confirmPWEditText = (EditText) findViewById(R.id.confirm_pw_edit); newPWEditText.setEnabled(false); confirmPWEditText.setEnabled(false); changePWButton.setEnabled(false); newPWEditText = (EditText) findViewById(R.id.new_pw_edit); confirmPWEditText = (EditText) findViewById(R.id.confirm_pw_edit); XMPPConnection xmppConnection; connectionThread = AccountManager.getInstance().getAccount(account).getConnectionThread(); if (connectionThread == null) { Application.getInstance().onError(R.string.NOT_CONNECTED); return; } xmppConnection = connectionThread.getXMPPConnection(); if (xmppConnection == null) { Application.getInstance().onError(R.string.NOT_CONNECTED); return; } am = new org.jivesoftware.smack.AccountManager(xmppConnection); oldPWEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { oldpassword = oldPWEditText.getText().toString(); if (oldpassword .equals(connectionThread.getConnectionItem().getConnectionSettings().getPassword())) { newPWEditText.setEnabled(true); confirmPWEditText.setEnabled(true); changePWButton.setEnabled(true); } } }); }
From source file:com.liangxun.university.huanxin.chat.activity.ChatActivity.java
/** * initView//from w w w.j a v a 2 s . c o m */ protected void initView() { layout_point = (LinearLayout) findViewById(R.id.iv_image); recordingContainer = findViewById(R.id.recording_container); micImage = (ImageView) findViewById(R.id.mic_image); recordingHint = (TextView) findViewById(R.id.recording_hint); listView = (ListView) findViewById(R.id.list); mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage); buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard); edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout); buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice); buttonSend = findViewById(R.id.btn_send); buttonPressToSpeak = findViewById(R.id.btn_press_to_speak); expressionViewpager = (ViewPager) findViewById(R.id.vPager); emojiIconContainer = (RelativeLayout) findViewById(R.id.ll_face_container); btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container); locationImgview = (ImageView) findViewById(R.id.btn_location); iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal); iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked); loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more); btnMore = (Button) findViewById(R.id.btn_more); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); more = findViewById(R.id.more); edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); // ?, micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01), getResources().getDrawable(R.drawable.record_animate_02), getResources().getDrawable(R.drawable.record_animate_03), getResources().getDrawable(R.drawable.record_animate_04), getResources().getDrawable(R.drawable.record_animate_05), getResources().getDrawable(R.drawable.record_animate_06), getResources().getDrawable(R.drawable.record_animate_07), getResources().getDrawable(R.drawable.record_animate_08), getResources().getDrawable(R.drawable.record_animate_09), getResources().getDrawable(R.drawable.record_animate_10), getResources().getDrawable(R.drawable.record_animate_11), getResources().getDrawable(R.drawable.record_animate_12), getResources().getDrawable(R.drawable.record_animate_13), getResources().getDrawable(R.drawable.record_animate_14), }; // list reslist = getExpressionRes(132); // ?viewpager views = new ArrayList<View>(); View gv1 = getGridChildView(1); View gv2 = getGridChildView(2); View gv3 = getGridChildView(3); View gv4 = getGridChildView(4); View gv5 = getGridChildView(5); View gv6 = getGridChildView(6); View gv7 = getGridChildView(7); views.add(gv1); views.add(gv2); views.add(gv3); views.add(gv4); views.add(gv5); views.add(gv6); views.add(gv7); expressionViewpager.setAdapter(new ExpressionPagerAdapter(views)); edittext_layout.requestFocus(); voiceRecorder = new VoiceRecorder(micImageHandler); buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen()); mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); } else { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal); } } }); mEditTextContent.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active); more.setVisibility(View.GONE); iv_emoticons_normal.setVisibility(View.VISIBLE); iv_emoticons_checked.setVisibility(View.INVISIBLE); emojiIconContainer.setVisibility(View.GONE); btnContainer.setVisibility(View.GONE); } }); // ? mEditTextContent.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { btnMore.setVisibility(View.GONE); buttonSend.setVisibility(View.VISIBLE); } else { btnMore.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); }
From source file:com.albedinsky.android.ui.widget.SearchView.java
/** * Called to inflate a view hierarchy of this view. * * @param context Context used to obtain an instance of LayoutInflater used to inflate a desired * layout resource as view hierarchy for this view. * @param resource Resource id of the layout which should represent a view hierarchy of this view. */// w w w. j a v a 2s .c o m private void inflateHierarchy(Context context, int resource) { LayoutInflater.from(context).inflate(resource, this); this.mEditText = (AutoCompleteTextViewWidget) findViewById(R.id.ui_search_input); this.mButtonIcon = (ImageButtonWidget) findViewById(R.id.ui_search_icon); this.mProgressBar = (CircularProgressBar) findViewById(R.id.ui_search_progress); this.mButtonClear = (ImageButtonWidget) findViewById(R.id.ui_search_clear); this.mButtonVoiceSearch = (ImageButtonWidget) findViewById(R.id.ui_search_mic); // fixme: remove this when voice search is implemented mButtonVoiceSearch.setVisibility(View.GONE); mEditText.addTextChangedListener(new TextWatcher() { /** */ @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Ignored. } /** */ @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Ignored. } /** */ @Override public void afterTextChanged(Editable s) { onQueryTextChange(s != null && s.length() > 0 ? new SpannableStringBuilder(s) : ""); } }); mEditText.setOnKeyListener(new View.OnKeyListener() { /** */ @Override public boolean onKey(View view, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: if (event.getAction() == KeyEvent.ACTION_UP) { onTextConfirmed(); } return true; } return false; } }); mButtonClear.setOnClickListener(CLICK_LISTENER); mButtonVoiceSearch.setOnClickListener(CLICK_LISTENER); }