मेरी समस्या को हल करने का प्रयास करने के लिए धन्यवाद!एक्सएमएल स्पलैश स्क्रीन -> प्रदर्शन वेबव्यू
वर्तमान में मेरा ऐप मूल रूप से एंड्रॉइड वेब व्यू का उपयोग कर एक वेब पेज लोड करता है। नकारात्मकता यह है कि कभी-कभी (खराब कनेक्शन के साथ) वेब पेज को लोड करने में 10 सेकंड लगते हैं। क्या वेब पेज लोड होने पर मैं किसी प्रकार का स्पलैश एक्सएमएल "लोडिंग" स्क्रीन बना सकता हूं?
मेरे कोड पर एक नज़र डालें ...
package com.ect;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.CookieSyncManager;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class SomeActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//THIS IS WHAT I WANT: setContentView(R.layout.main);
CookieSyncManager.createInstance(getBaseContext());
// Let's display the progress in the activity title bar, like the
// browser app does.
getWindow().requestFeature(Window.FEATURE_PROGRESS);
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//Users will be notified in case there's an error (i.e. no internet connection)
Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
public void onPageFinished(WebView view, String url) {
CookieSyncManager.getInstance().sync();
}
});
CookieSyncManager.getInstance().startSync();
CookieSyncManager.getInstance().sync();
//This will load the webpage that we want to see
webview.loadUrl("http://www.web.com/");
}
}
मेरी कोड है। यदि आप बारीकी से देखते हैं तो मैंने एक टिप्पणी की है जो कहती है, "यह वही है जो मैं चाहता हूं: ..."
वह टिप्पणी मुख्य.एक्सएमएल फ़ाइल को प्रदर्शित करने के लिए कॉल करेगी, लेकिन अगर मैं उस टिप्पणी का उपयोग main.xml फ़ाइल प्रदर्शित किया जाएगा, लेकिन वेबव्यू कभी प्रकट नहीं होता ...
मैं main.xml फ़ाइल को कैसे प्रदर्शित कर सकता हूं और फिर (वेब दृश्य लोड होने के बाद) वेबपृष्ठ प्रदर्शित करता है?
धन्यवाद पाइपरमैन! मैं एंड्रॉइड के साथ विकास करने के लिए पूरी तरह से नया हूं ... क्या कोई तरीका है कि आप मुझे कुछ कोड दे सकते हैं? – Joe