2012-03-23 71 views
0

我有一个其中包含浏览器的应用程序。我正在使用EditText作为我的地址栏来输入URL。当用户浏览webPage时,我需要隐藏它。就像它在android(默认)浏览器中发生的一样。请告诉我如何才能做到这一点。Android在webView滚动时隐藏EditText

回答

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(); 
      } 
     }); 
    } 
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切换不同的滚动型水平之间的公开程度..

+0

感谢您的回答。我们应该为此添加任何听众吗? – Droidme 2012-03-26 06:22:24

+0

我试过了。但该方法没有被触发(调用)。我应该添加一个监听器吗? – Droidme 2012-03-26 07:01:09

+0

是的,您应该将onScrollChangedListener设置为网页。 – 2012-03-26 16:40:22