1.如何調用外部圖片選擇器,選擇圖片并返回結果
//獲取照片
Intent in = new Intent(Intent.ACTION_GET_CONTENT);
in.setType("image/*");
startActivityForResult(in, 0);
然后Activity中還要加上一個結果返回接收
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);
System.out.println(intent.getDataString());
ImageView view = new ImageView(this);
view.setImageURI(intent.getData());
((LinearLayout)findViewById(R.id.layout)).addView(view);
System.out.println(requestCode);
}
2.如何調用Google Web Search?
其實android提供了一個很方便的調用方式,就是用Intent去調用系統的Activity,代碼如下:
//搜索
Intent search = new Intent(Intent.ACTION_WEB_SEARCH);
search.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
search.putExtra(SearchManager.QUERY, "tigertian");
final Bundle appData = getIntent().getBundleExtra(SearchManager.APP_DATA);
if (appData != null) {
search.putExtra(SearchManager.APP_DATA, appData);
}
startActivity(search);
執行這段代碼之后,就會跳轉到google的網站并自動搜索與tigertian相關的記錄
3.為什么WebView在進行loadUrl的時候,有時候會彈出Android的自帶瀏覽器進行瀏覽?
被訪問頁面如果不帶跳轉(Redirect)是不會彈出自帶瀏覽器的。但如果帶跳轉(Redirect)的話WebView是做不到的,所以他會調用相應的瀏覽器進行跳轉訪問。
4.有按鈕的列表項為可以點擊嗎?
可以,但是需要將按鈕的Focusable屬性置為false,Checkbox等控件同理。
5.android:layout_weight何時有效果?
<AutoCompleteTextView android:layout_height="wrap_content" android:layout_weight="2"
android:layout_width="wrap_content" android:completionThreshold="1"
android:id="@+id/AutoCompleteSearchGame"></AutoCompleteTextView>
當layout_height和layout_width都未wrap_content的時候有效果。
6、如果調用瀏覽器?
使用startActivity傳遞這個intent就可以調用瀏覽器了new Intent(Intent.ACTION_VIEW, Uri.parse(url))
---------------------------------------------------------
專注移動開發
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2009-04-30 11:09
TiGERTiAN 閱讀(3658)
評論(15) 編輯 收藏 所屬分類:
Java 、
Android