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

  • Home
  • SEARCH
  • 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 7824863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:44:27+00:00 2026-06-02T08:44:27+00:00

I have four imageviews which are set to invisible at activity start (or rather

  • 0

I have four imageviews which are set to invisible at activity start (or rather at row inflation). I would like to press a button and have them ALL become visible (and subsequently be operational as onclicks…). I have the following summary code, but I keep getting errors whenever I try to access any other imageview other than the last one.

public class xx {

    private ImageView up;
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // Log.i(TAG, "excersizeAdapter getView");
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.row, null);
            }

            Excersize e = items.get(position);
            if (e != null) {
                TextView exTitle      = (TextView) v.findViewById(R.id.ex_type_title);
                TextView exOn         = (TextView) v.findViewById(R.id.ex_on_title);
                TextView exRestAmount = (TextView) v.findViewById(R.id.ex_rest_amount);
                TextView exSequence   = (TextView) v.findViewById(R.id.ex_sequence);

                up                    = (ImageView) v.findViewById(R.id.moveup);
                down                  = (ImageView) v.findViewById(R.id.movedown);

                if (exTitle !=null) {
                    exTitle.setText(e.getTypeTitle());
                }

                if (exOn !=null) {
                    exOn.setText("On: "+e.getTypeOn());
                }

                if (exRestAmount !=null) {
                    exRestAmount.setText(e.getRestAmount().toString());
                }

                if (exSequence !=null) {
                    exSequence.setText(e.getSequence().toString());
                    up.setTag(8881);
                    down.setTag(8882);

                    up.setId(((Integer)e.getSequence()));
                    down.setId(((Integer)e.getSequence()));

                    Log.i(TAG, "up,down values=" +e.getSequence());
                }
            }
            return v;
        }
    }

    public void toggleReorderButtons() {
        up.findViewById(2).setVisibility(View.VISIBLE);
        up.setVisibility(View.VISIBLE);
        up.setOnClickListener(this);
    }
}

OK, this is cut down code, but in the makevisinvis method up.findview... it causes a crash and up.setvis, etc. will turn on only the last one that was added to my activity.

I also tried the following with no success.

ImageView upper = (ImageView) up.findViewById(2);
upper.setVisibility(View.VISIBLE);

A lovely error dump:

04-21 09:10:55.650: W/dalvikvm(22392): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
04-21 09:10:55.675: E/AndroidRuntime(22392): FATAL EXCEPTION: main
04-21 09:10:55.675: E/AndroidRuntime(22392): java.lang.NullPointerException
04-21 09:10:55.675: E/AndroidRuntime(22392):     at com.mediabarltd.digittrainer.ProgramDisplay.toggleReorderButtons(ProgramDisplay.java:437)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at com.mediabarltd.digittrainer.ProgramDisplay.onClick(ProgramDisplay.java:391)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at android.view.View.performClick(View.java:2538)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at android.view.View$PerformClick.run(View.java:9152)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at android.os.Handler.handleCallback(Handler.java:587)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at android.os.Looper.loop(Looper.java:130)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at android.app.ActivityThread.main(ActivityThread.java:3691)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at java.lang.reflect.Method.invokeNative(Native Method)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at java.lang.reflect.Method.invoke(Method.java:507)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
04-21 09:10:55.675: E/AndroidRuntime(22392):     at dalvik.system.NativeStart.main(Native Method)

It took some serious looking and a total rework of what I was doing. but…

Basically I followed the tutorial Android ListView and ListActivity and then implemented the neat ‘trick’ described in Android ListView Adapter OnClickListener issue.

(I’m really having a hard time with 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-06-02T08:44:29+00:00Added an answer on June 2, 2026 at 8:44 am

    You define up as a class member and re-init it every time getView gets called – therefore it always points to the last image view created. Also, I am not sure it is correct to call findViewById of up: instead set its OnClickListener inside getView and whenever clicked look for the required views inside a layout it belongs to.

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

Sidebar

Related Questions

I have four packages in my program, among them i would like one and
I have four checkboxpreferences in my preferencescreen that I would like to interact like
I have four videos that I would like to tile in a 2x2 fashion
I have four entities that I would like to translate into database tables via
I have four classes which share some arrangement of four properties. I have currently
i have four tables like below in sql server 2008 : TABLE 1 ->
I have four buttons on my page <button id=opener >Submit Timecard</button> <button id=cancel class=cancel>Cancel</button>
I have Four EditText with different background. It looks like this: I want to
I have four tables like the following : Cars: car_id | make_id 1 |
I have four activities, A, B, C and D. app starts with activity A,

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.