当webView滚动时,Android会隐藏EditText

时间:2012-03-23 10:05:18

标签: android webview scroll android-edittext

我有一个有浏览器的应用程序。我使用EditText作为我的地址栏来键入URL。我需要在用户浏览webPage时隐藏它。就像它在android(默认)浏览器中的情况一样。请告诉我如何做到这一点。

2 个答案:

答案 0 :(得分:0)

试试这段代码

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();
            }
        });
    }

答案 1 :(得分:0)

中检测滚动中的更改
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的可见性..