1,自定义虚拟键盘
当一个用户被要求在一个文本框输入时希望又怎样的体验? 从用户需求来看,虚拟键盘应该改变以帮助用户输入的数据。这里是一些例子:
- 如果一个视图是一个电子邮件地址,一个键盘的“@”符号容易应显示。
- 如果一个视图是用于Web地址,一个键盘。COM”按钮将是一个好主意。
- 如果一个视图是用于数字输入,键盘的数字应该显示给用户。
2,利用地理位置定位服务获取用户地址
有些表单会要求用户填写地址,在这种情况下,应用程序将打开位置管理器获取当前设备的纬度和经度,然后使用反向地理编码获取当前地址。最后将生成的地址在EditText视图。
//当前Activity实现接口ILocationListener
public class MainActivity : Activity, ILocationListener //--------------------------获取地址--------------------------------
public void OnLocationChanged(Location location)
{
GetAddress(location.Latitude, location.Longitude);
} void GetAddress(double lat, double lon)
{
try
{
EditText city=FindViewById<EditText>(Resource.Id.City);
IList<Address> a;
Geocoder geocoder = new Geocoder(this, Java.Util.Locale.Default);
a = geocoder.GetFromLocation(lat, lon, 10);
if (a != null && a.Count > 0)
{
var firstAddress = a[0];
var addressLine0 = firstAddress.GetAddressLine(0);
var locality = firstAddress.Locality;
var postalCode = firstAddress.PostalCode;
RunOnUiThread(() => city.Text = String.IsNullOrEmpty(locality) ? string.Empty : locality);
loctionManager.RemoveUpdates(this); }
}
finally { }
}
3,AutoCompleteTextView自动完成内容
可用于历史输入记录显示、国家/地区、引导用户完成输入
类似↓
4,滚动
通过ScrollView控件实现滚动,这样就允许应用程序用户界面在需要的时候进行滚动操作
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout ………>
……………………
</LinearLayout>
</ScrollView>