首先关于自动提示的效果

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="AutoCompleteTextView" />    <AutoCompleteTextView android:id="@+id/autotext"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:textColor="#000"        />    <TextView        android:id="@+id/textView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="MultiAutoCompleteTextView" />     <MultiAutoCompleteTextView          android:id="@+id/mul"         android:layout_width="fill_parent"           android:layout_height="wrap_content"         /></LinearLayout>

public class AutoActivity extends Activity {private AutoCompleteTextView auto;private MultiAutoCompleteTextView mult;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.autoeditext);auto=(AutoCompleteTextView) findViewById(R.id.autotext);mult=(MultiAutoCompleteTextView) findViewById(R.id.mul); String[] autoString=new String[]{"张航章","张航11","张航22","张航33","张航涨44",};ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,autoString);auto.setAdapter(adapter);auto.setTextColor(Color.BLACK);mult.setAdapter(adapter);mult.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());//完成对逗号的拆分}}

在编辑框中显示图片的效果

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <EditText        android:id="@+id/showimage"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:ems="10" >    </EditText>    <Button        android:id="@+id/btn_showimage"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" /></LinearLayout>

public class EditTextImage extends Activity{private EditText editText;private Button button;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.edittextimage);editText=(EditText) findViewById(R.id.showimage);button=(Button) findViewById(R.id.btn_showimage);button.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {try {int i=1+new Random().nextInt(4);Field field=R.drawable.class.getDeclaredField("face"+i);   int resourceId=Integer.parseInt(field.get(null).toString());   Bitmap bitmap=BitmapFactory.decodeResource(getResources(), resourceId);   ImageSpan imageSpan=new ImageSpan(EditTextImage.this,bitmap);   SpannableString spannableString=new SpannableString("face");   spannableString.setSpan(imageSpan, 0, 4,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);   editText.append(spannableString);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}});}}


还有一种效果验证表单的效果

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <TextView         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="使用android:digits属性(数字)"       />    <EditText android:layout_width="200dp"        android:layout_height="wrap_content"        android:layout_margin="10dp"        android:digits="0123456789"        android:id="@+id/edt_num"        />    <TextView         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="使用android:digits属性(字母)"       />    <EditText android:layout_width="200dp"        android:layout_height="wrap_content"        android:layout_margin="10dp"        android:digits="qwertyuiopasdfghjklmnbvcxz"        />        />    <TextView         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="使用android:inputType属性(数字)"       />    <EditText android:layout_width="200dp"        android:layout_height="wrap_content"        android:layout_margin="10dp"        android:inputType="number|textCapCharacters"        />    <TextView         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="使用android:inputType属性(邮箱)"       />    <EditText android:layout_width="200dp"        android:layout_height="wrap_content"        android:layout_margin="10dp"        android:inputType="textEmailAddress"        />    <TextView         android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="使用android:mersic属性(浮点)"       />    <EditText android:layout_width="200dp"        android:layout_height="wrap_content"        android:layout_margin="10dp"        android:numeric="decimal|signed"        />    <Button        android:id="@+id/btn_specail"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Button" /></LinearLayout>
public class SpecailActivity extends Activity { private Button button;private EditText editText;@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.specail);button=(Button) findViewById(R.id.btn_specail);editText=(EditText) findViewById(R.id.edt_num);button.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubString value=editText.getText().toString();if(value==null||value.trim().equals("")){editText.setError("请输入内容");}}});}}


更多相关文章

  1. Android实现计数器功能
  2. Android(安卓)点击输入框弹出日历 《H》
  3. android 分类联动效果 模仿每日优鲜
  4. 侧滑菜单(二)
  5. 定义界面布局TextView&Button
  6. ListView中一些效果的实现
  7. 2016-9-13
  8. Android(安卓)Studio用线性布局和相对布局做一个简单的登陆界面
  9. IOS 实现android Toast效果

随机推荐

  1. Android使用okhttp框架实现带参数Get和Po
  2. android强制横屏息屏后重新打开时会先显
  3. android 详细解答json解析与生成 JSONObj
  4. only the original thread that created
  5. 如何直接使用Android internal and hidde
  6. 关于android中进行http通信的几个问题
  7. json连接中央气象台api异常
  8. Android下如何计算要显示的字符串所占的
  9. 【Androidd Release】AndroidStudio 发布
  10. Android 图文数据JSON解析,金山词霸每日一