- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经为 Android 制作了一个应用内购买演示,我创建了一个测试产品并出于测试目的购买了它,一切都运行良好,但唯一的问题是当我在应用内结算对话框外点击时,它消失了,我想在上面做一些类似“setCancellable(false)”的事情,请建议我,我需要帮助,我的代码如下:
代码
package com.medicineqod.activity;
import inapUtils.IabHelper;
import inapUtils.IabHelper.OnConsumeFinishedListener;
import inapUtils.IabHelper.OnIabPurchaseFinishedListener;
import inapUtils.IabHelper.OnIabSetupFinishedListener;
import inapUtils.IabHelper.QueryInventoryFinishedListener;
import inapUtils.IabResult;
import inapUtils.Inventory;
import inapUtils.Purchase;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.drm.DrmStore.ConstraintsColumns;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.medicineqod.FragmentAbstractActivity;
import com.medicineqod.R;
import com.medicineqod.DBAdapter.DataBaseHelper;
import com.medicineqod.model.Question;
import com.medicineqod.utility.CommonVariables;
/**
* Created by basheer on 4/26/14.
*/
public class QuestionOFDayActivity extends FragmentAbstractActivity
/* OnIabSetupFinishedListener, OnIabPurchaseFinishedListener */{
// When requested, this adapter returns a WallpaperCollectionFragment,
// representing an object in the collection.
SectionsPagerAdapter mSectionsPagerAdapter;
ViewPager mViewPager;
ImageView btnNext, btnPrev;
static TextView tvError;
TextView tvDate;
TextView btnHome;
TextView tvTitle;
int mTotalCount;
int mPosition = 0;
int mActivity = 0;
ArrayList<Question> qusList = new ArrayList<Question>();
// edited by jigar
private static final String TAG = "com.medicineqod.inappbilling";
static IabHelper mHelper;
static final String ITEM_SKU = "com.medicineqod.product.one";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quizoftheday);
// ViewPager and its adapters use support library
// fragments, so use getSupportFragmentManager.
// Edited by jigar,....
showCustomeAlertValidation(QuestionOFDayActivity.this);
DataBaseHelper bBase = new DataBaseHelper(this);
mActivity = getIntent().getIntExtra(CommonVariables.ACTIVITY, 0);
if (mActivity == CommonVariables.FavQusAct) {
qusList = bBase.getFavQuestions();
mTotalCount = qusList.size();
} else if (mActivity == CommonVariables.PastQusAct) {
qusList = bBase.getPastQuestions();
mTotalCount = qusList.size();
} else if (mActivity == CommonVariables.QusOfTheDay) {
qusList = bBase.getQuestions();
mTotalCount = qusList.size();
} else {
qusList = bBase.getQuestions();
mTotalCount = qusList.size();
}
if (qusList.size() == 0) {
return;
}
mPosition = getIntent().getIntExtra("postion", 0);
Collections.reverse(qusList);
if (mPosition == -1) {
mPosition = qusList.size() - 1;
}
mSectionsPagerAdapter = new SectionsPagerAdapter(
getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setCurrentItem(mPosition);
tvError = (TextView) findViewById(R.id.error_tv);
tvDate = (TextView) findViewById(R.id.topbar_date_tv);
tvTitle = (TextView) findViewById(R.id.topbar_title_tv);
btnNext = (ImageView) findViewById(R.id.bottom_next_img);
btnPrev = (ImageView) findViewById(R.id.bottom_prev_img);
btnNext.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mTotalCount - 1 > mPosition) {
mPosition++;
mViewPager.setCurrentItem(mPosition);
}
}
});
btnPrev.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (0 < mPosition) {
mPosition--;
mViewPager.setCurrentItem(mPosition);
}
}
});
mViewPager
.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
mPosition = position;
btnNext.setVisibility(View.VISIBLE);
btnPrev.setVisibility(View.VISIBLE);
if (mPosition == 0) {
btnPrev.setVisibility(View.INVISIBLE);
} else if (mPosition == mTotalCount - 1) {
btnNext.setVisibility(View.INVISIBLE);
} else {
btnNext.setVisibility(View.VISIBLE);
btnPrev.setVisibility(View.VISIBLE);
}
tvDate.setText("" + qusList.get(position).getDate());
setTiltle(qusList.get(mPosition).getDate());
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
tvDate.setText("" + qusList.get(mPosition).getDate());
setTiltle(qusList.get(mPosition).getDate());
btnHome = (TextView) findViewById(R.id.topbar_left_tv);
if (mActivity == CommonVariables.FavQusAct) {
btnHome.setText("Back");
btnHome.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_back,
0, 0, 0);
} else if (mActivity == CommonVariables.PastQusAct) {
btnHome.setText("Back");
btnHome.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_back,
0, 0, 0);
} else if (mActivity == CommonVariables.QusOfTheDay) {
// btnHome.setText("Back");
// btnHome.setCompoundDrawablesWithIntrinsicBounds(null, null, null,
// null);
}
btnHome.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
overridePendingTransition(R.anim.slide_in_right,
R.anim.slide_out_right);
}
});
// System.out.println(mPosition + "::::" + (mTotalCount - 1));
if (qusList.size() == 0 || qusList.size() == 1) {
btnPrev.setVisibility(View.INVISIBLE);
btnNext.setVisibility(View.INVISIBLE);
} else if (mPosition == 0) {
btnPrev.setVisibility(View.INVISIBLE);
} else if (mPosition == mTotalCount - 1) {
btnNext.setVisibility(View.INVISIBLE);
} else {
btnNext.setVisibility(View.VISIBLE);
btnPrev.setVisibility(View.VISIBLE);
}
}
private void setTiltle(String date) {
if (mActivity == CommonVariables.FavQusAct) {
tvTitle.setText(""
+ getApplication().getResources().getString(
R.string.title_fav_qus));
} else if (getCurrentDate().equals(date)) {
tvTitle.setText(""
+ getApplication().getResources().getString(R.string.qod));
} else {
tvTitle.setText(""
+ getApplication().getResources().getString(
R.string.title_past_qus));
}
}
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
fragment = new QuizCollectionFragment();
Bundle args = new Bundle();
args.putSerializable(QuizCollectionFragment.ARG_OBJECT,
(Serializable) qusList.get(position));
args.putInt(QuizCollectionFragment.QUZI_POSITION, position);
fragment.setArguments(args);
return fragment;
}
@Override
public int getCount() {
return mTotalCount;
}
@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
return "good".toUpperCase(l);
}
}
public void setOnAnswer(String mPerformance, String mAswerView,
String mAswerQue, String mFavourite, int mPosition,
String mPercentage) {
if (qusList.size() > 0 && mPosition < qusList.size()) {
Question mQuizQuestion = qusList.get(mPosition);
mQuizQuestion.setAnsque(mAswerQue);
mQuizQuestion.setPerformance(mPerformance);
mQuizQuestion.setAnsview(mAswerView);
mQuizQuestion.setFavourite(mFavourite);
mQuizQuestion.setPercentage(mPercentage);
qusList.set(mPosition, mQuizQuestion);
}
}
public void refreshTheViewPage(int position) {
if (mActivity == CommonVariables.FavQusAct) {
tvDate.setText("");
qusList.remove(mPosition);
mTotalCount = qusList.size();
mSectionsPagerAdapter.notifyDataSetChanged();
mViewPager.setAdapter(mSectionsPagerAdapter);
if (mTotalCount - 1 < mPosition) {
mPosition = mTotalCount - 1;
}
mViewPager.setCurrentItem(mPosition);
btnNext.setVisibility(View.VISIBLE);
btnPrev.setVisibility(View.VISIBLE);
if (qusList.size() == 0 || qusList.size() == 1) {
btnNext.setVisibility(View.INVISIBLE);
btnPrev.setVisibility(View.INVISIBLE);
} else if (mPosition == 0) {
btnPrev.setVisibility(View.INVISIBLE);
} else if (mPosition == mTotalCount - 1) {
btnNext.setVisibility(View.INVISIBLE);
} else {
btnNext.setVisibility(View.VISIBLE);
btnPrev.setVisibility(View.VISIBLE);
}
}
}
// Popup of subscribing app..
public void showCustomeAlertValidation(final Context context) {
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.popup);
dialog.setCancelable(false);
dialog.getWindow().setBackgroundDrawable(
new ColorDrawable(android.graphics.Color.TRANSPARENT));
final Button btn_subscribe = (Button) dialog
.findViewById(R.id.btn_subscribe);
btn_subscribe.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Subscribing code here...!!!
mHelper.launchPurchaseFlow(QuestionOFDayActivity.this,
ITEM_SKU, 10001, mPurchaseFinishedListener,
"mypurchasetoken");
dialog.dismiss();
}
});
dialog.show();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
String base64EncodedPublicKey = "MIIBIjANyOvuqXSF8qd4NAapQdRohAajUA3/N/L9XoD21B7lVqZnICXh1dFEnnVvNyhK+ws1Cr5YsPvIAprHvsQNJ2xtEGypNivk/AA6N91OY0r2dtZJZHGpSxDSsfHTfKk5/4CaW1itbdIo+JiGTieJyHIvMFdWSkLqaxR3JWy+0KwTHvzMrR15oClM9v8fKjNT6M8qxlhnyzLDd7G2/ifBIPTJjfdvWHoXaP/rHa2MbN2acPwvbbwIDAQAB";
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Log.d(TAG, "In-app Billing setup failed: " + result);
} else {
Log.d(TAG, "In-app Billing is set up OK");
}
}
});
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {
// Handle error
return;
} else if (purchase.getSku().equals(ITEM_SKU)) {
consumeItem();
System.out
.println(":::::::::::::::::::::Purchase consumed successfuly::::::::::::::::::::");
}
}
};
IabHelper.QueryInventoryFinishedListener mReceivedInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result,
Inventory inventory) {
if (result.isFailure()) {
// Handle failure
} else {
mHelper.consumeAsync(inventory.getPurchase(ITEM_SKU),
mConsumeFinishedListener);
}
}
};
IabHelper.OnConsumeFinishedListener mConsumeFinishedListener = new IabHelper.OnConsumeFinishedListener() {
public void onConsumeFinished(Purchase purchase, IabResult result) {
if (result.isSuccess()) {
System.out
.println("::::::::::::::::::::::::Purchase consumehas been finished successfully:::::::::::::::::::::");
} else {
// handle error
System.out
.println("::::::::::::::::::::::::Purchase consumehas failed:::::::::::::::::::::");
}
}
};
public void consumeItem() {
mHelper.queryInventoryAsync(mReceivedInventoryListener);
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
if (mHelper != null)
mHelper.dispose();
mHelper = null;
}
}
最佳答案
这是您需要做的以限制它。
dialog.setCanceledOnTouchOutside(false);
这将确保在对话框区域外触摸时不会关闭对话框。
关于android - 当我在它外面点击时,我的应用程序内结算对话框消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25301966/
我在我的 Maven Java 项目中使用带有 slf4j 的 logback。当前 logback 配置文件 (logback.xml) 位于 src -> main -> resources 文件
这可能是个愚蠢的问题。我正在尝试像所附图片一样设置左/右页边距。我通过在UIScrollView中添加UITextView成功实现了。但是,我几乎可以单独使用 UITextView 实现我想要的一切。
我有一个游戏,其中有一个绿色圆圈在场景中的随机位置随机生成,每次点击该圆圈时,它都会改变位置,有可能会变成红色。当圆圈为红色时,我希望用户点击不是红色圆圈的屏幕空间。如何检测不在圆圈上的水龙头?我的圈
HTML: delete delete CSS: .container { position: relative; border:
我制作了正文 max-width: 2000px 和 overflow-x: hidden...我的内容超过了这个尺寸(position: absolute 和 left: -101%),它们在需要时
我这里有这个菜单 我希望突出显示(悬停)延伸到外部框(服务菜单)的边缘。就像弹出菜单一样。菜单本身包含在另一个 div 中 - 我认为负边框不可能像负填充那样存在。 有人知道如何在悬停时使菜单的高亮部
我正在使用 Vue-awesome-slider 作为轮播库,并想将滑动箭头放置在轮播主体之外。但是由于 carousel 容器溢出隐藏,我无法将它放在 carousel 之外。 https://gi
我是一名优秀的程序员,十分优秀!