Reputation: 23
fileHippoWrapper = (LinearLayout) findViewById(R.id.filehippo_wrapper2);
fileHippoWrapper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(FinalChatActivity.this, "FileHippo", Toast.LENGTH_SHORT).show();
AlAttachmentOptions.processLocationAction(getActivity(), null);
}
});
I'm not able import function processLocationAction
from another activity AlAttachmentOptions
it says
can't resolve method getActivity()
Upvotes: 1
Views: 5342
Reputation: 874
Additional note on @TruongHieu's answer, getActivity()
doesn't exist in onClick(View view)
, so you can't just call getActivity() from there.
In order to get the activity of current Activity, you need to do the samething as Toast statement.
Toast.makeText(FinalChatActivity.this, "FileHippo", Toast.LENGTH_SHORT).show();
AlAttachmentOptions.processLocationAction(FinalChatActivity.this, null);
Hope it helps.
Upvotes: -1
Reputation: 21766
There is no getActivity()
method in Android Activity. This is just to indicate that you need to get reference of your activity here.
So instead of getActivity()
, use this
Or FinalChatActivity.this
. It will work.
So your code will:
fileHippoWrapper = (LinearLayout) findViewById(R.id.filehippo_wrapper2);
fileHippoWrapper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(FinalChatActivity.this, "FileHippo", Toast.LENGTH_SHORT).show();
AlAttachmentOptions.processLocationAction(FinalChatActivity.this, null);
}
});
Upvotes: 3
Reputation: 3527
Use
AlAttachmentOptions.processLocationAction(FinalChatActivity.this, null);
Upvotes: 0