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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:26:32+00:00 2026-06-18T16:26:32+00:00

I have initialize object in class like following View popupView; //This is global I

  • 0

I have initialize object in class like following

View popupView; //This is global

I have created View object in onCreate() method like following

LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
popupView = layoutInflater.inflate(R.layout.activity_filter_form, null);

I want to access view object in setOnClickListener like following

popupView.setVisibility(View.VISIBLE);

But above line gives an error ” popupView cannot be resolved to a type “. Please help.

Full Code as following

public class Myclass1 extends Activity 
{
TextView tv_addiction_name, tv_today, tv_yesterday, tv_this_week, tv_this_month, tv_total;
ImageView iv_back, iv_filter;
int year, month, day;
int placeData;
Boolean state = false;
DatePickerDialog.OnDateSetListener dateListener;
SQLiteDatabase database;
int cat_id = 0;
View popupView;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_addiction_details);

    LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    popupView = layoutInflater.inflate(R.layout.activity_filter_addiction_form, null);
    popupView.setVisibility(View.INVISIBLE);

    Intent intent = getIntent();
    final String cat_name = intent.getStringExtra("cat_name");
    tv_addiction_name = (TextView) findViewById(R.id.textViewAddictionDetails);
    tv_addiction_name.setText(cat_name);

    tv_total = (TextView) findViewById(R.id.textview_total);
    tv_today = (TextView) findViewById(R.id.textview_today);
    tv_yesterday = (TextView) findViewById(R.id.textview_yesterday);
    tv_this_week = (TextView) findViewById(R.id.textview_this_week);
    tv_this_month = (TextView) findViewById(R.id.textview_this_month);

    iv_back = (ImageView) findViewById(R.id.imageViewAddictionDetailsBack);
    iv_back.setClickable(true);
    iv_back.setOnClickListener(new OnClickListener()
                                    {
                                        @Override
                                        public void onClick(View v)
                                        {
                                            Intent intent = new Intent(AddictionDetails.this, StartActivity.class);
                                            startActivity(intent);
                                        }
                                    }
                                );

    iv_filter = (ImageView) findViewById(R.id.imageViewAddictionDetailsFilter);
    iv_filter.setClickable(true);
    iv_filter.setOnClickListener(new OnClickListener()
                                    {
                                        @Override
                                        public void onClick(View v)
                                        {
                                            if(state == false)
                                            {
                                                state = true;
                                                popupView.setVisibility(View.VISIBLE); // Getting error on this line.
  • 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-18T16:26:34+00:00Added an answer on June 18, 2026 at 4:26 pm

    I think the member popupView is not visible in anonymous class OnClickListener. You should try to acces it via MyClass1.popupView.

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

Sidebar

Related Questions

I have created the following class class Contact def initialize(id, name, phone) @id =
I have two classes like the following: class Super(object): def __init__(self, arg): self.arg =
I have an object now: class Items attr_accessor :item_id, :name, :description, :rating def initialize(options
I have this class: public MyClass { public void initialize(Collection<String> data) { this.data =
I have a struct that I initialize like this: typedef struct { word w;
I have a class like the following: class A: def __init__(self, arg1, arg2, arg3):
I have a program doing something like the following: class SomeObject{} { void function(int
I have the following simplified ViewModel public class UserViewModel : IUserViewModel { public DelegateCommand<object>
I have the following method to create a new Connection object. It will open
I have a page object called LineItemsPage class LineItemsPage attr_accessor :add_line_item_button def initialize(test_env) @browser

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.