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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:24:51+00:00 2026-06-18T03:24:51+00:00

HI I am developing small android application. In my application I am showing one

  • 0

HI I am developing small android application. In my application I am showing one context menu.
every thing is working fine only problem is that I am not able to set header view to my context menu.
My code looks like

@Override
public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {

    super.onCreateContextMenu(menu, v, menuInfo);
    LayoutInflater headerInflater = (LayoutInflater) getSherlockActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    ViewGroup header = (ViewGroup) headerInflater.inflate(
            R.layout.context_menu_header, null);

    menu.setHeaderView(header);
    menu.setHeaderTitle("Edit Profile Pic");

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.menu_camera, menu);
}

and my layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

 <ImageView
        android:id="@+id/context_menu_header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/actionbar" 
        />
</LinearLayout>

It’s not taking that layout file as header view… I also read this Applying a custom header for ContextMenu

But that’s not working for me..
Need help thank you….

  • 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-18T03:24:52+00:00Added an answer on June 18, 2026 at 3:24 am

    If I set header title after set header view it’s not applying that view. Insted of that set header title in xml view itself and set title when u r applying header view. like in following manner..

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
        ContextMenuInfo menuInfo) {
    
    super.onCreateContextMenu(menu, v, menuInfo);
    LayoutInflater headerInflater = (LayoutInflater) getSherlockActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    
    ViewGroup header = (ViewGroup) headerInflater.inflate(
            R.layout.context_menu_header, null);
    
       // menu.setHeaderView(header);
      TextView title = (TextView) header
                    .findViewById(R.id.header_textView);
            title.setText("Edit Profile Pic");
        menu.setHeaderView(header);
    //menu.setHeaderTitle("Edit Profile Pic");
    
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.menu_camera, menu);
    }
    

    and it will work fine. Its same as this question Applying a custom header for ContextMenu.

    Thank you…

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

Sidebar

Related Questions

I am developing a small android application in that i want find the mobile
I am new to android application development. I am developing one small application.In this
I'm developing a small android mobile application with a tab based interface. One tab
I am developing a small application on Google's android emulator. I am trying to
I am developing a small application and for that authentication is needed. That I'm
I am developing a small android application. When the user hasn't signed up, he
I am developing an small application in a android. Before this i had done
I'm developing a small application but I'm having problem while deploying the application on
I am developing a small application in android in which i have few image
Hi am developing android application. I have some small doubt of how to change

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.