当前位置: 首页>>代码示例>>Java>>正文


Java AutoCompleteTextView.append方法代码示例

本文整理汇总了Java中android.widget.AutoCompleteTextView.append方法的典型用法代码示例。如果您正苦于以下问题:Java AutoCompleteTextView.append方法的具体用法?Java AutoCompleteTextView.append怎么用?Java AutoCompleteTextView.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.AutoCompleteTextView的用法示例。


在下文中一共展示了AutoCompleteTextView.append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EnterJidDialog

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public EnterJidDialog(
	final Context context, List<String> knownHosts, final List<String> activatedAccounts,
	final String title, final String positiveButton,
	final String prefilledJid, final String account, boolean allowEditJid
) {
	AlertDialog.Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(title);
	View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
	final TextView jabberIdDesc = (TextView) dialogView.findViewById(R.id.jabber_id);
	jabberIdDesc.setText(R.string.account_settings_jabber_id);
	final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
	final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
	jid.setAdapter(new KnownHostsAdapter(context, R.layout.simple_list_item, knownHosts));
	if (prefilledJid != null) {
		jid.append(prefilledJid);
		if (!allowEditJid) {
			jid.setFocusable(false);
			jid.setFocusableInTouchMode(false);
			jid.setClickable(false);
			jid.setCursorVisible(false);
		}
	}

	jid.setHint(R.string.account_settings_example_jabber_id);

	if (account == null) {
		StartConversationActivity.populateAccountSpinner(context, activatedAccounts, spinner);
	} else {
		ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
				R.layout.simple_list_item,
				new String[] { account });
		spinner.setEnabled(false);
		adapter.setDropDownViewResource(R.layout.simple_list_item);
		spinner.setAdapter(adapter);
	}

	builder.setView(dialogView);
	builder.setNegativeButton(R.string.cancel, null);
	builder.setPositiveButton(positiveButton, null);
	this.dialog = builder.create();

	this.dialogOnClick = new View.OnClickListener() {
		@Override
		public void onClick(final View v) {
			final Jid accountJid;
			if (!spinner.isEnabled() && account == null) {
				return;
			}
			try {
				if (Config.DOMAIN_LOCK != null) {
					accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
				} else {
					accountJid = Jid.fromString((String) spinner.getSelectedItem());
				}
			} catch (final InvalidJidException e) {
				return;
			}
			final Jid contactJid;
			try {
				contactJid = Jid.fromString(jid.getText().toString());
			} catch (final InvalidJidException e) {
				jid.setError(context.getString(R.string.invalid_jid));
				return;
			}

			if(listener != null) {
				try {
					if(listener.onEnterJidDialogPositive(accountJid, contactJid)) {
						dialog.dismiss();
					}
				} catch(JidError error) {
					jid.setError(error.toString());
				}
			}
		}
	};
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:78,代码来源:EnterJidDialog.java

示例2: EnterJidDialog

import android.widget.AutoCompleteTextView; //导入方法依赖的package包/类
public EnterJidDialog(
	final Context context, List<String> knownHosts, List<String> activatedAccounts,
	final String title, final String positiveButton,
	final String prefilledJid, final String account, boolean allowEditJid
) {
	AlertDialog.Builder builder = new AlertDialog.Builder(context);
	builder.setTitle(title);
	View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
	final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
	final AutoCompleteTextView jid = (AutoCompleteTextView) dialogView.findViewById(R.id.jid);
	jid.setAdapter(new KnownHostsAdapter(context,android.R.layout.simple_list_item_1, knownHosts));
	if (prefilledJid != null) {
		jid.append(prefilledJid);
		if (!allowEditJid) {
			jid.setFocusable(false);
			jid.setFocusableInTouchMode(false);
			jid.setClickable(false);
			jid.setCursorVisible(false);
		}
	}

	ArrayAdapter<String> adapter;
	if (account == null) {
		adapter = new ArrayAdapter<>(context,
			android.R.layout.simple_spinner_item, activatedAccounts);
	} else {
		adapter = new ArrayAdapter<>(context,
			android.R.layout.simple_spinner_item, new String[] { account });
		spinner.setEnabled(false);
	}
	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	spinner.setAdapter(adapter);

	builder.setView(dialogView);
	builder.setNegativeButton(R.string.cancel, null);
	builder.setPositiveButton(positiveButton, null);
	this.dialog = builder.create();

	this.dialogOnClick = new View.OnClickListener() {
		@Override
		public void onClick(final View v) {
			final Jid accountJid;
			try {
				if (Config.DOMAIN_LOCK != null) {
					accountJid = Jid.fromParts((String) spinner.getSelectedItem(), Config.DOMAIN_LOCK, null);
				} else {
					accountJid = Jid.fromString((String) spinner.getSelectedItem());
				}
			} catch (final InvalidJidException e) {
				return;
			}
			final Jid contactJid;
			try {
				contactJid = Jid.fromString(jid.getText().toString());
			} catch (final InvalidJidException e) {
				jid.setError(context.getString(R.string.invalid_jid));
				return;
			}

			if(listener != null) {
				try {
					if(listener.onEnterJidDialogPositive(accountJid, contactJid)) {
						dialog.dismiss();
					}
				} catch(JidError error) {
					jid.setError(error.toString());
				}
			}
		}
	};
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:72,代码来源:EnterJidDialog.java


注:本文中的android.widget.AutoCompleteTextView.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。