本文介绍了如何在适配器类中调用getIntent()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在getView()方法中,我想调用getIntent().我如何在不开始新活动的情况下实现这一目标.这样的getView方法

In getView() method I want to call getIntent(). How can I achieve this without starting a new activity. The getView method like this

public View getView(final int position, View convertView, ViewGroup parent) {
    PaymentData rowItem = getItem(position);
    LayoutInflater mInflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null) {
        convertView = mInflater.inflate(
                com.android.paypal.homeactivity.R.layout.list_item, null);
        holder = new ViewHolder();
        holder.radioBtn = (RadioButton) convertView
                .findViewById(com.android.paypal.homeactivity.R.id.rdb_payment_method);
        convertView.setTag(holder);
    } else
        holder = (ViewHolder) convertView.getTag();

    if (position == getCount() - 1 && userSelected == false) {
        holder.radioBtn.setChecked(true);
        mCurrentlyCheckedRB = holder.radioBtn;
    } else {
        holder.radioBtn.setChecked(false);
    }

    holder.radioBtn.setText(rowItem.getRdbText());
    return convertView;
}

推荐答案

以下是此问题的解决方案.

Here is the solution of this problem.

            Intent intent = ((Activity) context).getIntent();
            intent.putExtra("SELECTED_PAYMENT", mCurrentlyCheckedRB
                    .getText().toString());
            ((Activity) context).setResult(((Activity) context).RESULT_OK,
                    intent);
            ((Activity) context).finish();

这篇关于如何在适配器类中调用getIntent()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 12:30