Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6715343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:36:12+00:00 2026-05-26T08:36:12+00:00

I have a set a variable in my Base Adapter class, now I want

  • 0

I have a set a variable in my Base Adapter class, now I want to get(pass) this variable in my related Activity. I am not getting how to do this.

Here is my code.

  public class TourDescAdapter extends BaseAdapter {

    private List<Descriptions> descriptList;
    private LayoutInflater mInflater;
    ViewHolder holder;
    @SuppressWarnings("unused")
    private OnClickListener clickListener; 
    Activity context;
    //TourDescription tourDesc;
    ArrayList<HashMap<String, Object>> obj = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> discountedTourDetails = null;
    String price = null, prodId = null;
    String promoTourname, tourName;

    public TourDescAdapter(List<Descriptions> descriptList,
            TourDescription activity) {
        this.context = activity;
        this.descriptList = descriptList;
        mInflater = LayoutInflater.from(activity);
        clickListener = (OnClickListener) activity;

    }

    @Override
    public int getCount() {

        return this.descriptList.size();
    }

    @Override
    public Object getItem(int position) {

        return this.descriptList.get(position);

    }

    @Override
    public long getItemId(int position) {

        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.tourlist, null);

            /****
             * Creates a ViewHolder and store references to the two children
             * views we want to bind data to
             ****/
            holder = new ViewHolder();
            holder.rlayout = (RelativeLayout) convertView
                    .findViewById(R.id.tourlayout);

            holder.title = (TextView) convertView
                    .findViewById(R.id.tourtitletext);
            holder.desc = (TextView) convertView.findViewById(R.id.tourdes);
            holder.amountButton = (Button) convertView
                    .findViewById(R.id.amtBtn);
            holder.pinButton = (Button) convertView.findViewById(R.id.pinBtn);
            holder.arrowButton = (Button)convertView.findViewById(R.id.arrowBtn);
            holder.serialText = (EditText)convertView.findViewById(R.id.pinText);
            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();
        }

        holder.title.setText((String) descriptList.get(position)
                .getImageTitle());
        holder.desc.setText((String) descriptList.get(position)
                .getImageDescription());
        ((ImageView) holder.rlayout.getChildAt(0)).setImageBitmap(BitmapFactory
                .decodeFile((RaconTours.PATH + RaconTours.city + File.separator
                        + TourDescription.currentTour.getObjtourName()
                        + File.separator + descriptList.get(position)
                        .getImagePath().split("/")[2]).replace(" ", "_")));

        if (position == 0) {
            SharedPreferences settings = context.getSharedPreferences("downloadDetails", 0);
            String isTourDownloaded = settings.getString(TourDescription.currentTour.getObjtourName(), "");
            if (isTourDownloaded.equals("true")) {
            //if (!(TourDescription.downloadFile.exists())||TourDescription.downloadFile.exists() == false ) {
            //if (TourDescription.currentTour.getIsTourDownloaded() == true) {
                //holder.pinButton.setVisibility(View.INVISIBLE);
                //holder.arrowButton.setVisibility(View.INVISIBLE);
                //holder.serialText.setVisibility(View.INVISIBLE);
                }
                holder.amountButton.setVisibility(View.VISIBLE);
                holder.amountButton.setText("Start");



            } else {
                File promoPlistPath = new File(RaconTours.PATH + "promocode.txt");
                checkPromoCode(promoPlistPath);
                if (discountedTourDetails != null) {
                    tourName = (String) discountedTourDetails.get("promoTour");
                    price = (String) discountedTourDetails.get("discountPrice");
                    prodId = (String) discountedTourDetails.get("disProId");

                    holder.amountButton.setVisibility(View.VISIBLE);
                    // Setting the background color
                    holder.title
                            .setBackgroundColor(Color.parseColor("#993333"));
                    // Setting the Title color
                    holder.title.setTextColor(Color.WHITE);
                    // Centering the title
                    holder.title.setGravity(Gravity.LEFT);
                    // setting the city
                    ((TextView) holder.rlayout.getChildAt(1))
                            .setText(RaconTours.city);
                    ((TextView) holder.rlayout.getChildAt(1))
                            .setVisibility(View.VISIBLE);
                    // setting the Tour Amount
                    holder.amountButton.setText("$" +price);
                    //promoPlistPath.delete();
                } else {

                    // Enabling the two buttons
                    holder.amountButton.setVisibility(View.VISIBLE);
                    // Setting the background color
                    holder.title
                            .setBackgroundColor(Color.parseColor("#993333"));
                    // Setting the Title color
                    holder.title.setTextColor(Color.WHITE);
                    // Centering the title
                    holder.title.setGravity(Gravity.LEFT);
                    // setting the city
                    ((TextView) holder.rlayout.getChildAt(1))
                            .setText(RaconTours.city);
                    ((TextView) holder.rlayout.getChildAt(1))
                            .setVisibility(View.VISIBLE);
                    // setting the Tour Amount
                    holder.amountButton.setText(TourDescription.currentTour
                            .getObjPrice());

                }
            }
        } else {
            holder.amountButton.setVisibility(View.INVISIBLE);
            holder.pinButton.setVisibility(View.INVISIBLE);
            holder.arrowButton.setVisibility(View.INVISIBLE);
            holder.serialText.setVisibility(View.INVISIBLE);
            holder.title.setBackgroundColor(Color.WHITE);
            holder.title.setTextColor(Color.BLACK);
            holder.title.setGravity(Gravity.CENTER_HORIZONTAL);
            ((TextView) holder.rlayout.getChildAt(1))
                    .setVisibility(View.INVISIBLE);
        }
        return convertView;
    }


    @SuppressWarnings("unchecked")
    private void checkPromoCode(File promoPlistPath) {
        if (promoPlistPath.exists()) {
            try {

                ObjectInputStream inStream = new ObjectInputStream(
                        new FileInputStream(promoPlistPath));
                obj = (ArrayList<HashMap<String, Object>>) inStream
                        .readObject();
                for (HashMap<String, Object> tmpObj : obj) {
                    promoTourname = (String) tmpObj.get("promoTour");
                    if (promoTourname.equals(TourDescription.currentTour.getObjtourName())) {
                        discountedTourDetails = tmpObj;
                        break;
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    class ViewHolder {
        Button pinButton;
        Button amountButton;
        RelativeLayout rlayout;
        TextView title;
        TextView desc;
        Button arrowButton;
        EditText serialText;

    }
}

Here

    prodId = (String) discountedTourDetails.get("disProId");

I want to pass prodId to related activity.

Note: Base Adapter is called from the activity

    adapter = new TourDescAdapter(currentTour.getListOfDescriptions(), this);

    setListAdapter(adapter);

Any one can tell me how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:36:13+00:00Added an answer on May 26, 2026 at 8:36 am

    Couldn’t you just use String iGotTheString = adapter.prodId?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a static variable partner in the class. And I want to set
I have a base abstract logger class, that has an instance variable that I
I have a simple has_many through relationship set up: class Tag < ActiveRecord::Base has_many
My problem is that I have to set a variable in a try statement
I have set my default-input-method variable to english-dvorak: (custom-set-variables '(default-input-method english-dvorak)) When I launch
I have installed a servlet (solr) that requires that I set the variable solr.solr.home
I have the following code to set a userId variable: (userId set in prior
I have a variable define as: set filePath=.\file.txt I'm writing a windows batch file.
I have a variable, emailBody, which is set to a string stored in a
I have an existing panel where I set the html manually with a variable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.