나는 수 일 동안 검색했지만 답을 찾을 수 없습니다. 아마도 도움을 줄 수 있습니다.이클립스의 Android 앱
나는 이클립스에서 안드로이드 응용 프로그램을 만들고 있는데, 모든 것이 작동한다는 것은 저를 괴롭히는 것입니다.
package com.test;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;
public class Main extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Add Click listeners for all buttons
View firstButton = findViewById(R.id.btn_rassen);
firstButton.setOnClickListener(this);
View secondButton = findViewById(R.id.button2);
secondButton.setOnClickListener(this);
}
// Process the button click events
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.btn_rassen:
Intent j = new Intent(this, Webscreen.class);
j.putExtra(com.test.Webscreen.URL,
"http://www.google.com/");
startActivity(j);
break;
case R.id.button2:
Intent k = new Intent(this, Webscreen.class);
k.putExtra(com.test.Webscreen.URL,
"http://notworkingurltotest.com");
startActivity(k);
break;
}
}
}
이는 webview.java를 호출 할 때 현재라는 페이지가 표시되지만 내가 레이아웃 XML 페이지에서 생성되지 버튼 :
이
내 main.java입니다. 왜이 사람인지 아무도 몰라?귀하의 도움에 감사드립니다! 이 OHW
내 webscreen.java
package com.test;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class Webscreen extends Activity {
public static final String URL = "";
private static final String TAG = "WebscreenClass";
private WebView webview;
private ProgressDialog progressDialog;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.webscreen);
this.getIntent().getExtras();
this.webview = (WebView) findViewById(R.string.webview);
String turl = getIntent().getStringExtra(URL);
Log.i(TAG, " URL = "+turl);
WebView webview = new WebView(this);
setContentView(webview);
final Activity activity = this;
webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onLoadResource (WebView view, String url) {
if (progressDialog == null) {
progressDialog = new ProgressDialog(activity);
progressDialog.setMessage("Bezig met laden...");
progressDialog.show();
}
}
public void onPageFinished(WebView view, String url) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
progressDialog = null;
}
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Intent myIntent = new Intent();
myIntent.setClassName("com.test", "com.test.Main");
startActivity(myIntent);
Toast.makeText(activity, "Laden van onderdeel mislukt, probeer het later nog eens! ", Toast.LENGTH_LONG).show();
progressDialog.show();
}
});
webview.loadUrl(turl);
}
}
webscreen.xml 레이아웃입니다 : 당신이 설정 한 후 두 번째 웹보기를 만들고있는 것처럼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- <1> -->
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<EditText android:id="@+id/url" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:lines="1"
android:layout_weight="1.0" android:hint="http://"
android:visibility="visible" />
<Button android:id="@+id/go_button" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="go_button" />
</LinearLayout>
<!-- <2> -->
<WebView
android:id="@string/webview"
android:layout_width="fill_parent"
android:layout_height="0dip"
/>
</LinearLayout>
더 많은 정보가 필요하다고 생각합니다. 예를 들어 웹 화면 활동을위한 레이아웃 XML 파일은 무엇입니까? – C0deAttack
빠른 답장을 보내 주셔서 감사합니다 C0deAttack, 대단히 감사 드려요, 내 게시물에 레이아웃 코드를 추가했습니다. – Colin
내가 댓글을 달려면 : WebView webview = new WebView (this); setContentView (webview); 버튼과 텍스트 막대가로드되지만 페이지가 더 이상로드되지 않습니다.이 도움이 되길 바랍니다. – Colin