Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Is there a way to retrieve corresponding widget for callback methods? #48

Open
sangamk opened this issue Jun 18, 2018 · 9 comments
Labels

Comments

@sangamk
Copy link

sangamk commented Jun 18, 2018

For the callbacks apk.model.getCallbackMethodsis there a way to find the layout widget that calls that method? If there is one ofcourse.

public void click(View view){
}
<button android:onClick="click"/>

or for:

findById(id).setOnClickListener
@fgwei
Copy link
Contributor

fgwei commented Jun 19, 2018

Yes, the click method should be collected as callback method for getCallbackMethods.

@fgwei fgwei added the question label Jun 19, 2018
@sangamk
Copy link
Author

sangamk commented Jun 19, 2018

Yes but can I also find out which widget is linked to that method?
So I want to find this -> <button android:onClick="click"/>

@fgwei
Copy link
Contributor

fgwei commented Jun 20, 2018

@sangamk
Copy link
Author

sangamk commented Jun 20, 2018

For this ->

public void click(View view){
}
<button android:onClick="click"/>

I got it working.

However I can't find out how to find the buttonview (button2) for these kinds of methods ->

        Button b = findViewById(R.id.button2);
        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getApplicationContext(), ThirdActvity.class));
            }
        })

How would I go about doing this? Is there a way to see what view is passed on to the onClick method?

@sangamk
Copy link
Author

sangamk commented Jun 22, 2018

Anyone?

@fgwei
Copy link
Contributor

fgwei commented Jun 22, 2018

This onClick method will be automatically collected as a callback method for this component.
To find the view binding you need to do a point-to analysis to figure out when setOnClickListener get called which button object it is called upon and what is the OnClickListener is been registered.

@sangamk
Copy link
Author

sangamk commented Jun 22, 2018

Thx I will give it a try:
To clarify I am only interested in the type of the widget that calls the method not its name. So android.widget.Button or android.widget.TextView

@fgwei
Copy link
Contributor

fgwei commented Jun 22, 2018

You may use something like ExplicitValueFinder

@sangamk
Copy link
Author

sangamk commented Jun 28, 2018

So I got it working for most of the callbackmethods. However, I am missing some information. Specifically for menu items and support views. Is there a reason that Menus and support views are not part of the layoutcontrol or is it a missing feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants