这是一个非常幼稚的问题。我想从两个不同的按钮调用两个不同的类。下面的代码工作正常,但GalleryView.class只执行一次。我调用SelectImage.class的那一刻,这是一个对话似乎工作正常,但另一个只显示一次。请对此有所了解.
感谢和问候阿维吉特保罗
private Button button,button1;
public static String filename = "prefs";
SharedPreferences prefs;
public vp_default()
{
// TODO Auto-generated constructor stub
}
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
prefs = getSharedPreferences(filename,0);
button = (Button)findViewById(R.id.view_gallery_button);
button.setOnClickListener(this);
button1 = (Button)findViewById(R.id.sel_image_button);
button1.setOnClickListener(this);
}
@Override
public void onClick(View v)
{
String setPhnNo = "9231512345";
boolean stat = prefs.contains(setPhnNo);
switch(v.getId())
{
case R.id.view_gallery_button:
if(stat!=false)
{
startActivity(new Intent(getApplicationContext(), VirtualPainterActivity.class));
}
else
{
startActivity(new Intent(getApplicationContext(), GalleryView.class));
}
break;
case R.id.sel_image_button:
startActivity(new Intent(getApplicationContext(), SelectImage.class));
break;
}
}
}
//manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mcc.vp.apps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".vp_default" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".VirtualPainterActivity"
android:theme="@android:style/Theme.Dialog">
<intent-filter >
<action android:name="android.intent.action.vp_regn" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".GalleryView">
<intent-filter >
<action android:name="android.intent.action.vp_gview" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".SelectImage" >
<intent-filter >
<action android:name="android.intent.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".ViewImage">
<intent-filter >
<action android:name="android.intent.vp_view_img" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>