Android在webView滚动时隐藏编辑文本
我有一个应用程序,其中有一个浏览器。我使用EditText作为地址栏来键入URL。当用户浏览网页时,我需要隐藏此信息。就像在android(默认)浏览器中发生的那样。请告诉我如何做到这一点。尝试此代码Android在webView滚动时隐藏编辑文本,android,webview,scroll,android-edittext,Android,Webview,Scroll,Android Edittext,我有一个应用程序,其中有一个浏览器。我使用EditText作为地址栏来键入URL。当用户浏览网页时,我需要隐藏此信息。就像在android(默认)浏览器中发生的那样。请告诉我如何做到这一点。尝试此代码 public class Web_browser extends Activity { /** Called when the activity is first created. */ Button go; EditText webname; SharedPre
public class Web_browser extends Activity {
/** Called when the activity is first created. */
Button go;
EditText webname;
SharedPreferences webpref;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
go=(Button)findViewById(R.id.b_go);
webname=(EditText)findViewById(R.id.et_web_name);
go.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
webpref=Web_browser.this.getSharedPreferences("web_name",MODE_WORLD_WRITEABLE);
//webpref=PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor webnam =webpref.edit();
webnam.putString("web", webname.getText().toString());
webnam.commit();
Intent intent =new Intent(Web_browser.this,Webveiw.class);
startActivity(intent);
finish();
}
});
}
检测滚动中的更改
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
//code for detecting change in scroll goes here
//if satisfied with the level of scroll
editText.setVisibility(View.INVISIBLE);
}
在不同的滚动视图级别之间切换editText的可视性。谢谢您的回答。我们应该为此添加任何侦听器吗?我试过了。但该方法未被触发(调用)。我应该给它添加一个侦听器吗?