我正在构建一个应用程序,使用GeoCoder来自用户输入的街道地址。因此,我所做的一段代码:如何显示进度微调器?
Geocoder gc = new Geocoder(getBaseContext(), Locale.getDefault());
List<Address> addresses = null;
StringBuilder sb = new StringBuilder();
String destination = edittext_destination.getText().toString();
try {
addresses = gc.getFromLocationName(destination, 10);
} catch (Exception e){
Toast.makeText(getBaseContext(), "Address not found", Toast.LENGTH_SHORT).show();
}
上面的代码正在工作,但它需要一段时间才能返回结果。在等待结果时,我想显示进度微调器。我知道它应该使用线程但我不知道如何开始。我希望任何人都可以提供帮助。
谢谢
看看这篇文章:http://stackoverflow.com/a/6159735/543136 – TofferJ
http://stackoverflow.com/questions/8612406/android-os-networkonmainthreadexception-need-to-use-async-任务/ 8612418#8612418 –