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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:53:02+00:00 2026-05-26T12:53:02+00:00

I am developing Android Application. In which i am having list view with text

  • 0

I am developing Android Application. In which i am having list view with text and image. i need to set the imageview visible at run time. ie. when i clicked the view it should appear and when i click next view previous view have to disappear and corresponding imageview in clicking view have to appear.

Now i am success in displaying text but i am strucking in appearance of imageview. Inside the onclick of item list i cannot set the resource for imageview

Below is my code.

    public class ListofCategory extends Activity{
ListView listview;
List<String> mycategoryId,mycategoryName;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.listofcategory);
    listview=(ListView)findViewById(R.id.category_listview);
    mycategoryId=new ArrayList<String>();
    mycategoryName=new ArrayList<String>();
    getData();
    listview.setAdapter(new MyListAdapter(this));
     //setListAdapter(new MyListAdapter(this));
}

    class MyListAdapter extends BaseAdapter{
private Context context;

MyListAdapter(Context context)
{
    this.context=context;

}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return mycategoryId.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}


@Override
public View getView(final int position, View view, ViewGroup viewgroup) {

     ViewHolder holder = null;
    LayoutInflater inflater =  LayoutInflater.from(context);
            if (view == null) 
            {

              view = inflater.inflate(R.layout.mycategorylist, null);
    holder = new ViewHolder();
    holder.categoryname = (TextView) view.findViewById(R.id.title);
    holder.categorycount = (TextView) view.findViewById(R.id.description);
    holder.arrow=(ImageView)view.findViewById(R.id.arrow_imageview);
    view.setTag(holder);
 }
 else
 {
     holder = (ViewHolder) view.getTag();
 }
     holder.categoryname.setText(mycategoryName.get(position));
     holder.categoryname.setTextSize(18.0f);
     //holder.arrow.setImageResource(R.drawable.arrow);

     view.setOnClickListener(new OnClickListener() {

         @Override
         public void onClick(View v)
         {
            Problem occurs here..  This holder value ask me to change as final but here i cannot make holder to final
             holder.arrow.setImageResource(R.drawable.arrow);
            //finish(); 

         }
     });

 return view;
}


   }
 class ViewHolder
{
    TextView categoryname;
    TextView categorycount;
    ImageView arrow;

}

    }

Please anyone give me a better solution..its very urgent.. Thanks in advance

  • 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-26T12:53:03+00:00Added an answer on May 26, 2026 at 12:53 pm

    Create a final pointer for the imageView.

    final ImageView tempView = holder.arrow;
    

    than in the onclick:

    tempView.setImageResource(R.drawable.arrow);
    

    Added to the class a field:

    MyListAdapter myAdapter;
    

    In the oncreate method do this:

    myAdapter = new MyListAdapter(this);
    listview.setAdapter(myAdapter);
    

    On the onclick event do this:

    view.setOnClickListener(new OnClickListener() {    
    
         @Override    
         public void onClick(View v)    
         {    
            Problem occurs here..  This holder value ask me to change as final but here i cannot make holder to final    
             tempView.setImageResource(R.drawable.arrow);    
            myAdapter.notifyDataSetChange();    
    
         }    
     });   
    

    That should work.

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

Sidebar

Related Questions

I am developing an Android application which needs an image to be transmitted from
I am developing one android application which select wifi access point from list of
I'm now to android. And I'm having trouble in developing application in which I'm
We've been developing an Android application which includes Google Adsense. However there seems to
I'm having a go at developing my first android application and have never really
I am developing Android Application having ContactUs Page having Phone Number. I had given
Hi I m developing android application which recognize pattern, It si working as you
I am developing a android application which is running perfectly in motorola CLIQ(i installed
I am developing an Android application for which I would like to add Facebook
I am developing an android application in which i have created five tabs and

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.