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 6725141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:46:19+00:00 2026-05-26T09:46:19+00:00

I have few grid items. Depending on the flag, I want to disable some

  • 0

I have few grid items. Depending on the flag, I want to disable some grid items

For example:

  • Grid items are Order,CallLost,Payment. If boolean status = true, then I want to disable CallLost. Others should be enabled.
    • If boolean status = false, then I want to disable Order,Payment & CallLost

& I have done grid items using:

     @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.retailer_main);

        Bundle bundle = this.getIntent().getExtras();
        retailerName = bundle.getString("RetailerName");
        relailerCode = bundle.getString("RetailerCode");

        isDefault = bundle.getBoolean("isDefault", false);
        routeCode = bundle.getString("RouteCode");

        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

        SharedPreferences myRoutes = this.getSharedPreferences("myDefalutRoute",MODE_PRIVATE);
        defaultRoutePositions = myRoutes.getInt("defaultRoutePositions", -1);

        retailerGrid = (GridView)findViewById(R.id.retailergridview);
        retailerGrid.setAdapter(new RetailerImageAdapter(this));
        retailerGrid.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position,long id) {
                if (position == 0) {
                    Intent i = new Intent(getBaseContext(), RetailerOrderActivity.class);
                     Bundle bundle = new Bundle();
                     bundle.putString("Activity", "RetailerOptionActivity");
                     bundle.putString("RetailerName", retailerName);
                     bundle.putString("RetailerCode", relailerCode);
                     i.putExtras(bundle);
                    View vi = SalesActivityGroup.group.getLocalActivityManager().startActivity("RetailerOrderActivity", i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
                    SalesActivityGroup.group.replaceView(vi);

                }
                if (position == 2) {
                    Intent i = new Intent(getBaseContext(), CallLostActivity.class);
                     Bundle bundle = new Bundle();
                     bundle.putString("Activity", "RetailerOptionActivity");
                     bundle.putString("RetailerName", retailerName);
                     bundle.putString("RetailerCode", relailerCode);
                     i.putExtras(bundle);
                    View vi = SalesActivityGroup.group.getLocalActivityManager().startActivity("RetailerOrderActivity", i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
                    SalesActivityGroup.group.replaceView(vi);
                }
            }
        });

        Button reOpCancel = (Button)findViewById(R.id.reOpCancel);
        reOpCancel.setOnClickListener(new OnClickListener() {
               public void onClick(View v) {

                    Intent i = new Intent(getBaseContext(), ListRetailerActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putString("RetailerName", retailerName);
                    bundle.putString("RetailerCode", relailerCode);
                    bundle.putInt("positon", defaultRoutePositions);
                    bundle.putString("RouteCode", routeCode);
                    i.putExtras(bundle);
                    View vi = SalesActivityGroup.group.getLocalActivityManager().startActivity("ListRetailerActivity", i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
                    SalesActivityGroup.group.replaceView(vi);
                    isDefault = false;
                    //defaultRoutePositions = -1;
               }
        });
    }

    public void onCancelAction(View view){
        SalesActivityGroup.group.back();  
        return;
    }

    public void onCompleteAction(View view){
        SalesActivityGroup.group.back();  
        return;
    }

    public class RetailerImageAdapter extends BaseAdapter{
        Context MyContext;

        public RetailerImageAdapter(Context _MyContext){
            MyContext = _MyContext;
        }

        public int getCount() {
            return mThumbIds.length;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            View v;
            if(convertView==null){
                LayoutInflater li = getLayoutInflater();
                v = li.inflate(R.layout.grid_item, null);
                TextView tv = (TextView)v.findViewById(R.id.grid_item_text);
                tv.setText("Profile "+position);
                ImageView iv = (ImageView)v.findViewById(R.id.grid_item_image);
                tv.setText(names[position]);
                iv.setImageResource(mThumbIds[position]);
            }
            else
            {
                v = convertView;
            }
            return v;
        }

        public Object getItem(int arg0) {
            return null;
        }

//      public boolean  areAllItemsEnabled() {
//          return false;
//      }
//
//
//      public boolean  isEnabled(int position) {
//          if(isDefault){
//              if(position == 0) return true;
//              if(position == 1) return true;
//              if(position == 3) return true;
//              
//          }else{
//              if(position == 2) return false;
//          }
//          return false;
//      }


        public long getItemId(int arg0) {
            return 0;
        }

        // references to our images
        private Integer[] mThumbIds = { 
                R.drawable.one, R.drawable.two,
                R.drawable.five, R.drawable.four, 
                R.drawable.eight,R.drawable.seven,
                R.drawable.seven,R.drawable.seven,
                R.drawable.seven
            };
        private String[] names = {
                "Order","Order Flow",
                "Call Lost","Collection",
                "Cancel Invoice","Survey",
                "Complain","Customer Card",
                "ComInv"
        };
    }
}

Please any idea regarding this. I have seen this but it disables all items, just specific ones.

  • 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-26T09:46:20+00:00Added an answer on May 26, 2026 at 9:46 am

    I’m assuming that when you say “disable” you intend to make the grid item un-clickable (but still visible) — as in View.setEnabled().

    Try this in the RetailerImageAdapter.getView(), just before the return;

    if (isDefault && position == 2) {
        v.setEnabled(false);
    } else if (!default) {
        if (position == 0 | position == 1 | position == 3) {
            v.setEnabled(false);         
        }
    }
    

    I’m not positive this will work (I have not tested it), but it theoretically should.

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

Sidebar

Related Questions

I have a grid with a few items which have a checkbox at the
I have been working with the jQuery Grid the past few days and one
I have a FileNameEditor inside a property grid, which has a few entries like
I have few nested DIVs at page. I want to add event only for
I have few images in a grid, then when i click a button, a
I have a few 1000s triangles connected in a 2D mesh grid. It represents
I have few images which are retrieved from my web service. I want to
So I have a few items in a list that I display on my
Let's assume that I have defined two Grid s and few TextBox es in
I have few textboxes on one page and one user control. What I want

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.