2013-01-12 39 views
0

我有一个自定义的屏幕后退按钮,一旦用户点击我的屏幕的EditText后,我想将其更改为“隐藏键盘”。我找到了this question的一些很好的代码,关于检测键盘是否打开(查看Reuben Scratton的旧答案,了解我所做的)。我在java文件步骤:Android - 在键盘打开后更改按钮

@Override 
public void onSoftKeyboardShown(boolean isShowing) { 
    // do whatever you need to do here 
} 

我怎么会在这里输入代码后退按钮来改变它的形象一旦键盘打开?

这里是我的后退按钮当前的代码:我想将其更改为

<ImageButton 
     android:id="@+id/back" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@null" 
     android:contentDescription="Back" 
     android:scaleType="fitStart" 
     android:src="@drawable/back_bar" /> 

<ImageButton 
     android:id="@+id/back" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@null" 
     android:contentDescription="Back" 
     android:scaleType="fitStart" 
     android:src="@drawable/hide_keyboard" /> 

这里是我想要的情况下,做一个像我没有任何意义! image http://i47.tinypic.com/11vqvew.png

回答

0

你可以使用:

ImageButton backButton = (ImageButton)findViewById(R.id.back); 
backButton.setImageResource(R.drawable.hide_keyboard); 

onSoftKeyboardShown方法