當前位置: 首頁>>代碼示例>>Java>>正文


Java AutoCompleteTextView.setOnEditorActionListener方法代碼示例

本文整理匯總了Java中android.widget.AutoCompleteTextView.setOnEditorActionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java AutoCompleteTextView.setOnEditorActionListener方法的具體用法?Java AutoCompleteTextView.setOnEditorActionListener怎麽用?Java AutoCompleteTextView.setOnEditorActionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.AutoCompleteTextView的用法示例。


在下文中一共展示了AutoCompleteTextView.setOnEditorActionListener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import android.widget.AutoCompleteTextView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    editSummaryContainer = inflater.inflate(R.layout.fragment_preview_summary, container, false);
    summaryText = (AutoCompleteTextView) editSummaryContainer.findViewById(R.id.edit_summary_edit);

    // Explicitly enable standard dictionary autocompletion in the edit summary box
    // We should be able to do this in the XML, but doing it there doesn't work. Thanks Android!
    summaryText.setInputType(summaryText.getInputType() & (~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE));

    // ...so that clicking the "Done" button on the keyboard will have the effect of
    // clicking the "Next" button in the actionbar:
    summaryText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if ((keyEvent != null
                    && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))
                    || (actionId == EditorInfo.IME_ACTION_DONE)) {
                parentActivity.clickNextButton();
            }
            return false;
        }
    });

    return editSummaryContainer;
}
 
開發者ID:gnosygnu,項目名稱:xowa_android,代碼行數:26,代碼來源:EditSummaryFragment.java

示例2: setup

import android.widget.AutoCompleteTextView; //導入方法依賴的package包/類
private void setup() {
    mSearchText = (AutoCompleteTextView) findViewById(R.id.etInput);
    mSearchText.addTextChangedListener(this);
    mSearchText.setHint(getString(R.string.search_map));
    findViewById(R.id.search_back).setOnClickListener(view -> {
        finish();
    });
    mSearchText.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_SEARCH) {
            doSearch();
        }
        return false;
    });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:PoiAroundSearchActivity.java

示例3: generate

import android.widget.AutoCompleteTextView; //導入方法依賴的package包/類
/**
 * @param editField    The component to "transform" into one that shows a city drop down list
 *                     based on the current input. Make sure to pass an initialized object,
 *                     else a java.lang.NullPointerException will be thrown.
 * @param listLimit    Determines how many items shall be shown in the drop down list at most.
 */
public void generate(AutoCompleteTextView editField, int listLimit, final int enterActionId, final MyConsumer<City> cityConsumer, final Runnable selectAction) {
    cityAdapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, new ArrayList<City>());
    this.editField = editField;
    this.cityConsumer = cityConsumer;
    this.listLimit = listLimit;
    editField.setAdapter(cityAdapter);
    editField.addTextChangedListener(new TextChangeListener());

    editField.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectedCity = (City) parent.getItemAtPosition(position);
            cityConsumer.accept(selectedCity);
        }
    });

    editField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == enterActionId) {
                Boolean checkCity = checkCity();
                if (checkCity) {
                    selectAction.run();
                }
                return true;
            }
            return false;
        }
    });
}
 
開發者ID:SecUSo,項目名稱:privacy-friendly-weather,代碼行數:38,代碼來源:AutoCompleteCityTextViewGenerator.java

示例4: onCreate

import android.widget.AutoCompleteTextView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    getTheme().applyStyle(SharedPrefs.getFontSize().getResId(), true);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_search);

    UtilFunctions.applyReadingMode();

    languageCode = SharedPrefs.getString(Constants.PrefKeys.LAST_OPEN_LANGUAGE_CODE, "ENG");
    versionCode = SharedPrefs.getString(Constants.PrefKeys.LAST_OPEN_VERSION_CODE, Constants.VersionCodes.ULB);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white);
    toolbar.setContentInsetStartWithNavigation(0);
    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.auto_complete_search);
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    noResultsFound = (LinearLayout) findViewById(R.id.no_results_found);
    mIvClose = (ImageView) findViewById(R.id.iv_close);
    mRecyclerView = (RecyclerView) findViewById(R.id.list_results);
    sectionGroupView = (RadioGroup) findViewById(R.id.section_group);
    numOfResults = (TextView) findViewById(R.id.numResults);

    sectionGroupView.setOnCheckedChangeListener(this);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new SearchAdapter(this, mShowSearchResultModels);
    mRecyclerView.setAdapter(mAdapter);

    mIvClose.setOnClickListener(this);
    mAutoCompleteTextView.setOnClickListener(this);

    mAutoCompleteTextView.setOnEditorActionListener(this);
}
 
開發者ID:friendsofagape,項目名稱:Autographa-Go,代碼行數:41,代碼來源:SearchActivity.java

示例5: onCreate

import android.widget.AutoCompleteTextView; //導入方法依賴的package包/類
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	this.manPages = initPages();
	ArrayAdapter<Page> manPagesAdapter = new ArrayAdapter<Page>(this,
			android.R.layout.simple_list_item_1, manPages);
	ArrayAdapter<Page> manPagesCompleteAdapter = new ArrayAdapter<Page>(
			this, android.R.layout.simple_dropdown_item_1line, manPages);

	// Main list of all manpages
	ListView manPagesView = (ListView) findViewById(R.id.pages_names);
	manPagesView.setAdapter(manPagesAdapter);
	manPagesView.setOnItemClickListener(new OnManpageClickListener(this));

	// List of manpages displayed in the text field suggestions
	AutoCompleteTextView manPagesCompleteTextView = (AutoCompleteTextView) findViewById(R.id.search_input);
	manPagesCompleteTextView.setAdapter(manPagesCompleteAdapter);
	manPagesCompleteTextView
			.setOnItemClickListener(new OnManpageClickListener(this));

	// Check the availability of files on external storage
	if (!checkPageFilesOnExternalStorage(null))
		suggestDownload();

	// Handle the Enter key in the TextView
	// Get the input TextView
	AutoCompleteTextView input = (AutoCompleteTextView) findViewById(R.id.search_input);
	// Create a new handler for the Enter key ("Go" key here)
	TextView.OnEditorActionListener enterKeyListener = new TextView.OnEditorActionListener() {
		@Override
		public boolean onEditorAction(TextView v, int actionId,
				KeyEvent event) {
			// If search key was hit, search for this manpage
			if (actionId == EditorInfo.IME_ACTION_SEARCH
					|| actionId == EditorInfo.IME_NULL) {
				Page p = getManpageCalled(v.getText().toString());
				if (p != null) {
					// display it if found,
					displayManpage(p);
				} else {
					// else display an error message
					Toast.makeText(getApplicationContext(),
							"This manpage does not exist...",
							Toast.LENGTH_LONG).show();
				}
			}
			return true;
		}
	};
	input.setOnEditorActionListener(enterKeyListener);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:55,代碼來源:ManualActivity.java

示例6: showAddFilterDialog

import android.widget.AutoCompleteTextView; //導入方法依賴的package包/類
private void showAddFilterDialog(final FilterAdapter filterAdapter) {

        // show a popup to add a new filter text
        LayoutInflater inflater = getLayoutInflater();
        @SuppressLint("InflateParams")
        final AutoCompleteTextView editText =
                (AutoCompleteTextView) inflater.inflate(R.layout.dialog_new_filter, null, false);

        // show suggestions as the user types
        List<String> suggestions = new ArrayList<>(mSearchSuggestionsSet);
        SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<>(
                this, R.layout.list_item_dropdown, suggestions);
        editText.setAdapter(suggestionAdapter);

        final MaterialDialog alertDialog = new MaterialDialog.Builder(this)
                .title(R.string.add_filter)
                .positiveText(android.R.string.ok)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        handleNewFilterText(editText.getText().toString(), filterAdapter);
                        dialog.dismiss();
                    }
                })
                .negativeText(android.R.string.cancel)
                .customView(editText, true)
                .build();

        // when 'Done' is clicked (i.e. enter button), do the same as when "OK" is clicked
        editText.setOnEditorActionListener(new OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    // dismiss soft keyboard

                    handleNewFilterText(editText.getText().toString(), filterAdapter);

                    alertDialog.dismiss();
                    return true;
                }
                return false;
            }
        });

        alertDialog.show();

        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(editText, 0);

    }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:52,代碼來源:LogcatActivity.java


注:本文中的android.widget.AutoCompleteTextView.setOnEditorActionListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。