① android代碼如何 讓 edittext失去焦點
EditText初始化時候失去焦點:只需要在布局文件中設置屬性
java">android:focusable="false"
也可以在代碼中由開發者根據需求設置一定的條件,當條件滿足後,動態的設置EditText失去焦點。
示例代碼:
EditTextet=(EditText)findViewById(R.id.et);
et.clearFocus();
et.setFocusable(false);
這種控制EditText的操作是Android程序中不經常用到的。多出現於EditText的輸入監聽回調方法中。
② android開發 如何讓Activity或者布局失去焦點,像彈出Dialog一樣。
你可以在整個布局文件中嵌套一個空的布局,讓這個空布局去獲取焦點,這樣你另一個布局中的控制項就不會獲取焦點了,這個我以前用過,肯定好用。
③ Android中EditText獲得焦點後馬上又失去了,可能是什麼造成的呢
有以下幾種情況:
EditText處在一個可以滾動的控制項中,例如ListView等,當得到焦點後軟體鍵盤會彈出,這個時候滾動控制項會重繪,因此會失去焦點。
EditText注冊了焦點事件,得到焦點後將焦點轉向了其它控制項。
EditText禁止了獲取焦點。
④ android 怎樣讓button失去焦點
三種方法可以試試。
1、button.setFocusable(false);
2、如果只是為了進入的時候不要讓某個控制項得到焦點,可以設置焦點到整個Layout。
3、也可以在屏幕的空白處 就是你的deittext的父容器(例如你把文本框放在了LinearLayout布局中)可以給父容器添加事件使其失去焦點。
⑤ Android中EditText獲得焦點後馬上又失去了,可能是什麼造成的呢
丟失焦點就可以了。
⑥ android 輸入框失去焦點,怎樣讓鍵盤不自
1. 在activity layout xml文件中,EditText的前面定義:
<LinearLayout android:focusable="true" android:focusableInTouchMode="true" android:layout_width="0px" android:layout_height="0px" />
2. 在EditText中添加nextFocusUp與nextFocusLeft
<EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/editText" android:nextFocusUp="@id/editText" android:nextFocusLeft="@id/editText" />
⑦ 請教androidi imageview點擊丟失焦點問題
iv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Log.d("dd", "123");
}
});
2、圖片的id是項目自動生成的
在的值在R.java文件裡面
你可以把你要顯示的圖片的id放到一個數據裡面
int image_id = {R.id.imageView1,R.id.imageView2,....};
然後通過數據的位置
訪問id為imageView5的即
v.findViewByid(image_id[4]);
追問
第1個問題回答的很好,第2個問題,我需要用到這個int型i而不是手動打123...
如果有一百個,豈不是要打一百次,我想最終循環解決
不知java是如何組合這些東西的,也沒有js中的eval方法
例如: int numABC = 123;
String aa = "num";
String bb = "ABC";
光給你aa與bb兩個變數,如何輸出123
⑧ android 開發 ,控制整個屏幕的點擊功能屏幕失去焦點功能問題: 求思路啊~~
button.setEnabled(false),單獨的控制項可以這樣設置變成灰色和不可點擊狀態,你可以用ImageButton放圖標,通過它的監聽事件去修改其他控制項的setEnabled值。
⑨ 怎麼讓android 頁面失去焦點
在網上找了好久,有點監聽軟鍵盤事件,有點調用 clearFouse()方法,但是測試了都沒有!xml中也找不到相應的屬性可以關閉這個默認行為
1 解決之道:在EditText的父級控制項中找一個,設置成
Android:focusable="true"
android:focusableInTouchMode="true"
這樣,就把EditText默認的行為截斷了!
<LinearLayout
style="@style/FillWrapWidgetStyle"
android:orientation="vertical"
android:background="@color/black"
android:gravity="center_horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
>
<ImageView
android:id="@+id/logo"
style="@style/WrapContentWidgetStyle"
android:background="@drawable/dream_dictionary_logo"
/>
<RelativeLayout
style="@style/FillWrapWidgetStyle"
android:background="@drawable/searchbar_bg"
android:gravity="center_vertical"
>
<EditText
android:id="@+id/searchEditText"
style="@style/WrapContentWidgetStyle"
android:background="@null"
android:hint="Search"
android:layout_marginLeft="40dp"
android:singleLine="true"
/>
</RelativeLayout>
</LinearLayout>
2 還有一個方法也可以非常簡單的實現這個功能:
EditText對象的clearFocus();
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editMsgView.getWindowToken(), 0);(關閉軟鍵盤。。。)
3更多問題解決辦法請參考android學習手冊,例子、源碼、文檔全部搞定,採用androidstudo的目錄結構,360手機助手中下載。下面是截圖。
⑩ android 怎麼讓edittext失去焦點
1、在EditText的父布局中的布局文件中設置這兩行代碼
android:focusable="true"
android:focusableInTouchMode="true"
2、在代碼中設置EditText焦點通過setFocusable()和setFocusableInTouchMode() 不過這個好像不怎麼管用
3、如果你是不是想跳轉到有EditText的界面時自動彈出軟鍵盤的話 可以在功能清單文件(AndroidManifest.xml) 中的相對應activity節點中設置軟鍵盤彈出模式
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"