2011-04-27 3 views
1

아래에 두 개의 단추가있는 간단한 웹보기가 만들어졌습니다. 단추 중 하나를 누르면보기가 "웹"이라는 새보기를 만든 다음 페이지가로드되고 아래에 내 단추가 있지만 작동하지 않습니다. 전화에서 뒤로 버튼을 사용하면 빈 페이지를 열어보기로 전환되고 버튼이 다시 작동합니까? 죄송합니다, 새로운 ...웹 사이트로드 후 웹보기 단추가 작동하지 않습니다.

그냥 원래보기에서로드하고 버튼을 계속 작동 시키길 원합니다.

어떻게 든 새보기의 생성을 억제해야합니까?

친절 감사를

- 마이크

을 ** 나는 내 코드는 항상 내가 클립 보드에 복사 할 때이 does't 때문에 나는 그것을 게시 여분의 쓰레기를 가지고 이유를 모르겠습니다. **

enter image description here

package com.example.cam; 

수입에는 android.app.Activity; import android.os.Bundle; 가져 오기 android.webkit.WebView;

public class 웹 화면 확장 작업 { WebView webview1;

public static final String URL = "";

/** Called when the activity is first created. */ 
@Override 

공개 무효에서 onCreate (번들 savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.main); 문자열 turl = getIntent(). getStringExtra (URL);

webview1 = (WebView) findViewById (R.id.webview01);

webview1.clearCache (true); webview1.loadUrl (turl);

} 

}

package com.example.cam; 

수입에는 android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; 가져 오기 android.view.View.OnClickListener;

public class cam extends 활동 구현 OnClickListener { /** 활동이 처음 생성 될 때 호출됩니다. */ @Override public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.본관);

// Add Click listeners for all buttons 
    View firstButton = findViewById(R.id.button1); 
    firstButton.setOnClickListener(this); 
    View secondButton = findViewById(R.id.button2); 
    secondButton.setOnClickListener(this); 
    } 

// 버튼을 처리 클릭 이벤트 공공 무효 온 클릭 (보기 V) {

switch(v.getId()){ 
     case R.id.button1: 
      Intent j = new Intent(this, Webscreen.class); 
      j.putExtra(com.example.cam.Webscreen.URL, 
       "http://m.yahoo.com"); 
      startActivity(j); 
     break; 
     case R.id.button2: 
      Intent k = new Intent(this, Webscreen.class); 
      k.putExtra(com.example.cam.Webscreen.URL, 
       "http://m.google.com"); 
      startActivity(k); 
     break; 

    } 
} 

}

답변

1
내가 왜 Button 클래스를 사용하여보기를 사용하지 않는 모르는

수업. 대신 버튼에 버튼

0

의 배치

View b1=findViewById(R.id.button1); 

사용 상대 레이아웃의 사용

Button b1=(Button)findViewById(R.id.button1); 

는 웹 페이지/S를 표시하는 목적으로 활동를 재현하는 을 클릭합니다.

Intent j = new Intent(this, Webscreen.class); 
     j.putExtra(com.example.cam.Webscreen.URL, 
      "http://m.yahoo.com"); 
     startActivity(j); 

그것은 단지 당신이 대신 버튼 클릭의 웹 페이지를로드 할 필요 새로운 활동의 위에 새로운 활동을 만드는 것입니다.

//on button1 click 
mWebView.loadUrl("http://m.yahoo.com"); 
관련 문제