Java Code Examples for android.widget.EditText#setOnKeyListener()

The following examples show how to use android.widget.EditText#setOnKeyListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HyperTextEditor.java    From YCCustomText with Apache License 2.0 6 votes vote down vote up
/**
 * 添加生成文本输入框
 * @param hint								内容
 * @param paddingTop						到顶部高度
 * @return
 */
private EditText createEditText(String hint, int paddingTop) {
	EditText editText = new DeletableEditText(getContext());
	LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	editText.setLayoutParams(layoutParams);
	editText.setTextSize(16);
	editText.setTextColor(Color.parseColor("#616161"));
	editText.setCursorVisible(true);
	editText.setBackground(null);
	editText.setOnKeyListener(keyListener);
	editText.setOnFocusChangeListener(focusListener);
	editText.addTextChangedListener(textWatcher);
	editText.setTag(viewTagIndex++);
	editText.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop);
	editText.setHint(hint);
	editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize);
	editText.setTextColor(rtTextColor);
	editText.setHintTextColor(rtHintTextColor);
	editText.setLineSpacing(rtTextLineSpace, 1.0f);
	HyperLibUtils.setCursorDrawableColor(editText, cursorColor);
	return editText;
}
 
Example 2
Source File: Pinview.java    From Pinview with MIT License 5 votes vote down vote up
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
Example 3
Source File: SearchBookContentsActivity.java    From barcodescanner-lib-aar with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 4
Source File: SearchBookContentsActivity.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && initialQuery.length() > 0) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = (Button) findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 5
Source File: SearchBookContentsActivity.java    From zxingfragmentlib with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 6
Source File: KeyBoardUtils.java    From zone-sdk with MIT License 5 votes vote down vote up
/**
 * 监听输入法的回车按键
 */
public static void setEnterKeyListener(EditText editText, final View.OnClickListener listener) {
	editText.setOnKeyListener(new View.OnKeyListener() {
		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			// 这两个条件必须同时成立,如果仅仅用了enter判断,就会执行两次
			if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
				listener.onClick(v);
				return true;
			}
			return false;
		}
	});
}
 
Example 7
Source File: SplashActivity.java    From DoubleViewPager with Apache License 2.0 5 votes vote down vote up
private void loadUI(){

        title = (TextView) findViewById(R.id.splash_title);
        title.setTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
        line = (LinearLayout) findViewById(R.id.splash_line);
        logo = (ImageView) findViewById(R.id.splash_logo);
        data = (LinearLayout) findViewById(R.id.splash_data);
        button = (Button) findViewById(R.id.splash_button);

        ((TextView) findViewById(R.id.splash_data_horizontal_childs_tv)).setTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
        ((TextView) findViewById(R.id.splash_data_vertical_childs_tv)).setTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));

        etHorizontal = (EditText) findViewById(R.id.splash_data_horizontal_childs_et);
        etVertical = (EditText) findViewById(R.id.splash_data_vertical_childs_et);
        etHorizontal.setInputType(InputType.TYPE_CLASS_NUMBER);
        etVertical.setInputType(InputType.TYPE_CLASS_NUMBER);
        etVertical.setOnKeyListener(this);

        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                goToMain();
            }
        });

    }
 
Example 8
Source File: SearchBookContentsActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 9
Source File: SearchBookContentsActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !Intents.SearchBookContents.ACTION.equals(intent.getAction())) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 10
Source File: SearchBookContentsActivity.java    From reacteu-app with MIT License 4 votes vote down vote up
@Override
 public void onCreate(Bundle icicle) {
   super.onCreate(icicle);

fakeR = new FakeR(this);

   // Make sure that expired cookies are removed on launch.
   CookieSyncManager.createInstance(this);
   CookieManager.getInstance().removeExpiredCookie();

   Intent intent = getIntent();
   if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
     finish();
     return;
   }

   isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
   if (LocaleManager.isBookSearchUrl(isbn)) {
     setTitle(getString(fakeR.getId("string", "sbc_name")));
   } else {
     setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn);
   }

   setContentView(fakeR.getId("layout", "search_book_contents"));
   queryTextView = (EditText) findViewById(fakeR.getId("id", "query_text_view"));

   String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
   if (initialQuery != null && initialQuery.length() > 0) {
     // Populate the search box but don't trigger the search
     queryTextView.setText(initialQuery);
   }
   queryTextView.setOnKeyListener(keyListener);

   queryButton = (Button) findViewById(fakeR.getId("id", "query_button"));
   queryButton.setOnClickListener(buttonListener);

   resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view"));
   LayoutInflater factory = LayoutInflater.from(this);
   headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"),
       resultListView, false);
   resultListView.addHeaderView(headerView);
 }
 
Example 11
Source File: SearchActivity.java    From wallpaper with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	hasSearchResultDataFetched = false;
	setContentView(R.layout.activity_search);
	searchHistoryListView = (ListView) findViewById(R.id.search_history_listview);
	searchResultListView = (ListView) findViewById(R.id.search_result_listview);
	// set adapter

	if (null == UserCenter.instance().getSearchHistoryList(SearchActivity.this)) {
		searchResultListView.setVisibility(View.GONE);
	} else {
		ArrayList<String> historyList = UserCenter.instance().getSearchHistoryList(SearchActivity.this);
		SearchHistoryListViewAdapter adapter = new SearchHistoryListViewAdapter(this, historyList);
		searchHistoryListView.setAdapter(adapter);
		isSearch = true;
	}

	contentEditText = (EditText) findViewById(R.id.search_content_edittext);
	contentEditText.addTextChangedListener(this);

	searchHistoryListView.setOnItemClickListener(this);
	searchResultListView.setOnItemClickListener(this);

	contentEditText.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_ENTER) {// 修改回车键功能
				if (contentEditText.getText().toString().trim().length() > 0) {
					((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(SearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
					UserCenter.instance().addSearchHistoryList(contentEditText.getText().toString(), SearchActivity.this);
					SearchDetailViewModel viewModel = (SearchDetailViewModel) ViewModelManager.manager().newViewModel(SearchListActivity.class.getName());
					viewModel.wd = contentEditText.getText().toString().trim();
					Route.route().nextController(SearchActivity.this, viewModel, Route.WITHOUT_RESULTCODE);
				}
			}
			return false;
		}
	});
}
 
Example 12
Source File: PostFormActivity.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
private void setViews() {
    setContentView(settings.isPinnedMarkup() ? R.layout.postform_layout_pinned_markup : R.layout.postform_layout);
    nameLayout = findViewById(R.id.postform_name_email_layout);
    nameField = (EditText) findViewById(R.id.postform_name_field);
    emailField = (EditText) findViewById(R.id.postform_email_field);
    passwordLayout = findViewById(R.id.postform_password_layout);
    passwordField = (EditText) findViewById(R.id.postform_password_field);
    chkboxLayout = findViewById(R.id.postform_checkbox_layout);
    sageChkbox = (CheckBox) findViewById(R.id.postform_sage_checkbox);
    sageChkbox.setOnClickListener(this);
    custommarkChkbox = (CheckBox) findViewById(R.id.postform_custommark_checkbox);
    attachmentsLayout = (LinearLayout) findViewById(R.id.postform_attachments_layout);
    spinner = (Spinner) findViewById(R.id.postform_spinner);
    subjectField = (EditText) findViewById(R.id.postform_subject_field);
    commentField = (EditText) findViewById(R.id.postform_comment_field);
    markLayout = (LinearLayout) findViewById(R.id.postform_mark_layout);
    for (int i=0, len=markLayout.getChildCount(); i<len; ++i) markLayout.getChildAt(i).setOnClickListener(this);
    captchaLayout = findViewById(R.id.postform_captcha_layout);
    captchaView = (ImageView) findViewById(R.id.postform_captcha_view);
    captchaView.setOnClickListener(this);
    captchaView.setOnCreateContextMenuListener(this);
    captchaLoading = findViewById(R.id.postform_captcha_loading);
    captchaField = (EditText) findViewById(R.id.postform_captcha_field);
    captchaField.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                send();
                return true;
            }
            return false;
        }
    });
    sendButton = (Button) findViewById(R.id.postform_send_button);
    sendButton.setOnClickListener(this);
    
    if (settings.isHidePersonalData()) {
        nameLayout.setVisibility(View.GONE);
        passwordLayout.setVisibility(View.GONE);
    } else {
        nameLayout.setVisibility(boardModel.allowNames || boardModel.allowEmails ? View.VISIBLE : View.GONE);
        nameField.setVisibility(boardModel.allowNames ? View.VISIBLE : View.GONE);
        emailField.setVisibility(boardModel.allowEmails ? View.VISIBLE : View.GONE);
        passwordLayout.setVisibility((boardModel.allowDeletePosts || boardModel.allowDeleteFiles) ? View.VISIBLE : View.GONE);
        
        if (boardModel.allowNames && !boardModel.allowEmails) nameField.setLayoutParams(getWideLayoutParams());
        else if (!boardModel.allowNames && boardModel.allowEmails) emailField.setLayoutParams(getWideLayoutParams());
    }
    
    boolean[] markupEnabled = {
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_QUOTE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_BOLD),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_ITALIC),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_UNDERLINE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_STRIKE),
            PostFormMarkup.hasMarkupFeature(boardModel.markType, PostFormMarkup.FEATURE_SPOILER),
    };
    if (markupEnabled[0] || markupEnabled[1] || markupEnabled[2] || markupEnabled[3] || markupEnabled[4] || markupEnabled[5]) {
        markLayout.setVisibility(View.VISIBLE);
        if (!markupEnabled[0]) markLayout.findViewById(R.id.postform_mark_quote).setVisibility(View.GONE);
        if (!markupEnabled[1]) markLayout.findViewById(R.id.postform_mark_bold).setVisibility(View.GONE);
        if (!markupEnabled[2]) markLayout.findViewById(R.id.postform_mark_italic).setVisibility(View.GONE);
        if (!markupEnabled[3]) markLayout.findViewById(R.id.postform_mark_underline).setVisibility(View.GONE);
        if (!markupEnabled[4]) markLayout.findViewById(R.id.postform_mark_strike).setVisibility(View.GONE);
        if (!markupEnabled[5]) markLayout.findViewById(R.id.postform_mark_spoiler).setVisibility(View.GONE);
    } else {
        markLayout.setVisibility(View.GONE);
    }
    
    subjectField.setVisibility(boardModel.allowSubjects ? View.VISIBLE : View.GONE);
    chkboxLayout.setVisibility(boardModel.allowSage || boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    sageChkbox.setVisibility(boardModel.allowSage ? View.VISIBLE : View.GONE);
    custommarkChkbox.setVisibility(boardModel.allowCustomMark ? View.VISIBLE : View.GONE);
    if (boardModel.customMarkDescription != null) custommarkChkbox.setText(boardModel.customMarkDescription);
    spinner.setVisibility(boardModel.allowIcons ? View.VISIBLE : View.GONE);
    
    if (boardModel.allowIcons) {
        spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, boardModel.iconDescriptions));
    }
}
 
Example 13
Source File: PinEntryWrapper.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
private void registerListeners() {
    for (EditText editText : digits) {
        editText.addTextChangedListener(textWatcher);
        editText.setOnKeyListener(keyListener);
    }
}
 
Example 14
Source File: PassWordInputLayout.java    From AndroidProjects with MIT License 4 votes vote down vote up
private void removeBackspaceListener(final EditText et) {
    et.setOnKeyListener(null);
}
 
Example 15
Source File: FirstRunActivity.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    Fabric.with(this, new Crashlytics());
    if (prefs.getBoolean(FIRST_RUN, false)) {
        startActivity(new Intent(getApplicationContext(), HomeActivity.class));
        finish();
    }
    setContentView(R.layout.activity_first_run);


    findViewById(R.id.focus_thief).clearFocus();
    Animation anim_bounceinup=AnimationUtils.loadAnimation(getBaseContext(),R.anim.bounceinup);
    name = (EditText) findViewById(R.id.first_name);
    name.startAnimation(anim_bounceinup);
    name.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                    case KeyEvent.KEYCODE_DPAD_CENTER:
                    case KeyEvent.KEYCODE_ENTER:

                        if (name.getText().toString().equals("")) {
                            name.setError(getApplicationContext().getResources().getString(R.string.enter_name));
                            return false;
                        }
                        else if(!Character.isLetterOrDigit(name.getText().toString().charAt(0)))
                        {
                            name.setError(getApplicationContext().getResources().getString(R.string.valid_msg));
                            return false;
                        }


                        SharedPreferences.Editor editor = prefs.edit();

                        editor.putString(getString(R.string.key_user_name), name.getText().toString());
                        editor.putBoolean(FIRST_RUN, true);
                        editor.apply();
                        Intent intent = new Intent(getApplicationContext(), TutorialActivity.class);
                        intent.putExtra(Constants.START_ACTIVITY, true);
                        startActivity(intent);
                        finish();
                        return true;
                    default:
                        break;
                }
            }
            return false;
        }
    });
}
 
Example 16
Source File: MountServerActivity.java    From samba-documents-provider with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  mCache = SambaProviderApplication.getDocumentCache(this);
  mTaskManager = SambaProviderApplication.getTaskManager(this);
  mShareManager = SambaProviderApplication.getServerManager(this);
  mClient = SambaProviderApplication.getSambaClient(this);

  mNeedPasswordCheckbox = (CheckBox) findViewById(R.id.needs_password);
  mNeedPasswordCheckbox.setOnClickListener(mPasswordStateChangeListener);

  mPasswordHideGroup = findViewById(R.id.password_hide_group);

  mSharePathEditText = (BrowsingAutocompleteTextView) findViewById(R.id.share_path);
  mSharePathEditText.setOnKeyListener(mMountKeyListener);

  mUsernameEditText = (EditText) findViewById(R.id.username);
  mDomainEditText = (EditText) findViewById(R.id.domain);
  mPasswordEditText = (EditText) findViewById(R.id.password);
  mPasswordEditText.setOnKeyListener(mMountKeyListener);

  final Button mMountShareButton = (Button) findViewById(R.id.mount);
  mMountShareButton.setOnClickListener(mMountListener);

  final Button cancel = (Button) findViewById(R.id.cancel);
  cancel.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View view) {
      finish();
    }
  });

  setNeedsPasswordState(false);

  // Set MovementMethod to make it respond to clicks on hyperlinks
  final TextView gplv3Link = (TextView) findViewById(R.id.gplv3_link);
  gplv3Link.setMovementMethod(LinkMovementMethod.getInstance());

  mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);

  restoreSavedInstanceState(savedInstanceState);

  startBrowsing();
}
 
Example 17
Source File: TicketOnlineAty.java    From Huochexing12306 with Apache License 2.0 4 votes vote down vote up
private void initViews() {
	mStartPage = getIntent().getStringExtra(EXTRA_START_PAGE);
	mPostParams = getIntent().getStringExtra(EXTRA_POST_PARAMS);
	
	llytAddrBar = (LinearLayout)findViewById(R.id.llyt1);
	etUrl = (EditText) findViewById(R.id.content);
	btnGo = (ImageButton)findViewById(R.id.ok);
	btnGo.setOnClickListener(this);
	pb1 = (ProgressBar)findViewById(R.id.pb1);
	btnBack = (ImageButton)findViewById(R.id.back);
	btnBack.setOnClickListener(this);
	btnForward = (ImageButton)findViewById(R.id.forward);
	btnForward.setOnClickListener(this);
	btnHome = (ImageButton)findViewById(R.id.home);
	btnHome.setOnClickListener(this);
	btnStop = (ImageButton)findViewById(R.id.stop);
	btnStop.setOnClickListener(this);
	btnRefesh = (ImageButton)findViewById(R.id.refesh);
	btnRefesh.setOnClickListener(this);
	llytWebViewContainer = (LinearLayout)findViewById(R.id.ticketOnline_llytWebViewContainer);
	wv1 = WebViewUtil.buildWebView(this, pb1);
	wv1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
	llytWebViewContainer.addView(wv1);
	etUrl.setOnKeyListener(new OnKeyListener() {
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			if (event.getAction() == KeyEvent.ACTION_DOWN) {
				switch (keyCode) {
				case KeyEvent.KEYCODE_ENTER:
					String url = etUrl.getText().toString();
					if (!url.startsWith("http://") || !url.startsWith("https://")){
						url = "http://" + url;
					}
					wv1.loadUrl(url);
					InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
					inputManager.hideSoftInputFromWindow(
							etUrl.getWindowToken(), 0);
					return true;
				default:
					break;
				}
			}
			return false;
		}
	});
	if (HttpUtil.isNetworkConnected(this)){
		if (mStartPage == null || "".equals(mStartPage)){
			etUrl.setText(mHomePage);
			wv1.loadUrl(mHomePage);
		}else{
			if (mPostParams == null){
				etUrl.setText(mStartPage);
				wv1.loadUrl(mStartPage);
			}else{
				//以post方式打开页面
				llytAddrBar.setVisibility(View.GONE);
				wv1.postUrl(mStartPage, EncodingUtils.getBytes(mPostParams, "BASE64"));
			}
		}
	}else{
		showMsg("没有网络" + SF.NO_NETWORK);
	}
}
 
Example 18
Source File: SearchActivity.java    From wallpaper with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	hasSearchResultDataFetched = false;
	setContentView(R.layout.activity_search);
	searchHistoryListView = (ListView) findViewById(R.id.search_history_listview);
	searchResultListView = (ListView) findViewById(R.id.search_result_listview);
	// set adapter

	if (null == UserCenter.instance().getSearchHistoryList(SearchActivity.this)) {
		searchResultListView.setVisibility(View.GONE);
	} else {
		ArrayList<String> historyList = UserCenter.instance().getSearchHistoryList(SearchActivity.this);
		SearchHistoryListViewAdapter adapter = new SearchHistoryListViewAdapter(this, historyList);
		searchHistoryListView.setAdapter(adapter);
		isSearch = true;
	}

	contentEditText = (EditText) findViewById(R.id.search_content_edittext);
	contentEditText.addTextChangedListener(this);

	searchHistoryListView.setOnItemClickListener(this);
	searchResultListView.setOnItemClickListener(this);

	contentEditText.setOnKeyListener(new OnKeyListener() {

		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event) {
			if (keyCode == KeyEvent.KEYCODE_ENTER) {// 修改回车键功能
				if (contentEditText.getText().toString().trim().length() > 0) {
					((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(SearchActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
					UserCenter.instance().addSearchHistoryList(contentEditText.getText().toString(), SearchActivity.this);
					SearchDetailViewModel viewModel = (SearchDetailViewModel) ViewModelManager.manager().newViewModel(SearchListActivity.class.getName());
					viewModel.wd = contentEditText.getText().toString().trim();
					Route.route().nextController(SearchActivity.this, viewModel, Route.WITHOUT_RESULTCODE);
				}
			}
			return false;
		}
	});
}
 
Example 19
Source File: MainActivity.java    From mini-hacks with MIT License 3 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    itemListView = (ListView)findViewById(R.id.itemListView);
    itemListView.setOnItemClickListener(this);
    itemListView.setOnItemLongClickListener(this);

    addItemEditText = (EditText)findViewById(R.id.newItemText);
    addItemEditText.setOnKeyListener(this);
    addItemEditText.requestFocus();
    //Couchbase initialization code goes here - See steps 4, 6, 9, and 16.
    //Step 4 - Start Couchbase Lite


    //Step 6 - Call the 'initItemListAdapter' method


    //Step 9 - Call the 'startLiveQuery' method within the 'onCreate' method


    //Step 15 - Call the 'startSync' method within the 'onCreate' method



}
 
Example 20
Source File: List12.java    From codeexamples-android with Eclipse Public License 1.0 3 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.list_12);
    
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings);
    
    setListAdapter(mAdapter);
    
    mUserText = (EditText) findViewById(R.id.userText);

    mUserText.setOnClickListener(this);
    mUserText.setOnKeyListener(this);
}