Cris Marinho
Cris Marinho

Reputation: 3

How can I get the View received by OnClick without calling it?

The code below works perfect:

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

    Button button = (Button) this.findViewById(R.id.btn1);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            method.show(v);
        }
    });
}

However, I need to get View without using onClick

The code below does not work

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

    Button button = (Button) this.findViewById(R.id.btn1);

    method.show(button);
}

How can I get the same View as passed to button.onClick?

Thank you very much.

Upvotes: 0

Views: 154

Answers (1)

Ole
Ole

Reputation: 7979

I'm afraid you can't show a PopupWindow from onCreate().

Check out this answer

Upvotes: 1

Related Questions