我知道有一种方法可以在按钮点击时更改应用程序默认主题.Blackmart开发人员已经做到了.我已经在Google上搜索了1000页,但我发现这个(不工作)
getApplication().setTheme(Theme.Holo)
Run Code Online (Sandbox Code Playgroud)
由于我已经在res/values/styles.xml中创建了一个新样式,还有其他方法可以动态更改它吗?甚至重启应用程序?
我的菜单中有一个按钮,里面有一个“促销代码”。我需要检查用户是否已经点击了它,以便我可以告诉他(下次他点击它时)“You already redeemed this promo code!”我该怎么做?我只需要一段代码,我可以在其中检查按钮是否被点击。
@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean clicked = false;
switch (item.getItemId()) {
case R.id.getcode:
SharedPreferences pref = getSharedPreferences("promo", MODE_PRIVATE);
boolean activated = pref.getBoolean("activated", false);
if(activated == false) { Button btn = (Button) findViewById(R.id.getcode);
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage(getString(R.string.congrats) + "\n" + getString(R.string.promcd) + "\n" + "ASC2013-"+Build.ID+"-"+android.os.Build.SERIAL.charAt(3)+"-"+Build.SERIAL.charAt(6)+"-"+Build.SERIAL.charAt(9)+"-"+Build.SERIAL.charAt(12));
dlgAlert.setPositiveButton(R.string.go,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"lorenzocascio@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.validreq)+Build.BOOTLOADER);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.why) …Run Code Online (Sandbox Code Playgroud) android boolean buttonclick sharedpreferences android-button