嗨,谢谢你阅读我的问题。我是新来的,所以请容忍我。我有一个应用程序,我把它分成两个活动
我在两个布局中都有一个ImageView,它在加载WebViews时充当一个启动屏幕。它被标记为“可见”,而WebView和TabViews则标记为“消失”。
signIn WebView是主要的入口点,并在后台加载。如果一切都很好,就会加载一页带有“符号”的页面。我的WebViewClient正在使用onPageFinished(WV,Str)方法侦听。
问题:
我似乎无法成功地从signIn Activity (ActivityNotFoundException)调用该(ActivityNotFoundException)。
我在“宣言”中列出了这两项活动。
我在我最后的两个应用程序中做了这件事,所以我要疯了。
我可能已经修改了太多的代码,并且犯了一个明显的错误。请原谅我。
我已经尝试直接从WVC中startActivity(Intent),并通过调用另一个方法startTabView(),所以有额外的代码是令人困惑的。
我已经尝试过先声明意图,添加组件并调用startActivity(context, intent)。
我写了一行startActivity(new Intent("string class name"))。
我觉得我的意图可能是无效的。
看一下:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
phoneID = "" + tm.getDeviceId() ;
onStart();
}
public void setLoginVisible(){
ImageView splash = (ImageView) findViewById(R.id.splash);
splash.setVisibility(View.GONE);
signIn.setVisibility(View.VISIBLE);
signIn.requestFocus();
Toast.makeText(getApplicationContext(), phoneID, Toast.LENGTH_LONG);
}
public void startTabView(){
try{
startActivity( new Intent(this,WizForex.class));
}catch (ActivityNotFoundException anf){
Toast.makeText(getApplicationContext(), anf.toString(), Toast.LENGTH_LONG).show();
}catch (Exception e){
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG);
}
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
wvc= new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if (url.contains("NCdisclaimer")) setLoginVisible();
else if (url.contains("symbol")){
startTabView();
}
}
};
signIn = (WebView) findViewById(R.id.signIn);
signIn.getSettings().setJavaScriptEnabled(true);
signIn.setWebViewClient(wvc);
signIn.loadUrl("http://www.thewizard........"+ phoneID);
}<?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"
>
<!-- Splash View -->
<ImageView
android:id="@+id/splash"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:src="@drawable/splash"
android:visibility="visible"/>
<!-- signIn View -->
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/signIn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
/>
</LinearLayout><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Eric.Sheasby.wiz"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="WizFinder"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".WizForex"
android:label="@string/app_name">
</activity>
<activity android:name=".Tester"
android:label="@string/tester">
`抱歉这么长时间。我做了什么?
发布于 2011-04-16 06:45:47
问题可能是您是从操作处理程序(另一个线程,而不是ui!)中调用startTabView()的。
您应该尝试实例化一个处理程序(mHandler):
private static final int LOAD_TABVIEW = 10; //or any other number
private final Handler handler = new Handler()
{
public void handleMessage(Message msg)
{
switch (msg.what)
{
case LOAD_TABVIEW:
startTabView();
break;
default:
break;
}
};
};在onPageFinished(WebView view, String url)方法中,您应该更改一行
startTabView();至
//send message to the handler:
mHandler.sendEmptyMessage(LOAD_TABVIEW);通过这种方式调用mHandler的handleMessage,它应该启动TabView。
https://stackoverflow.com/questions/5684930
复制相似问题