Problem
I'm trying to create some extra behaviors on some native Android components.
For this I am creating a class
above the Android component and rewriting some situations that I want to behave differently, and I came across a situation that I need in my custom method, calling a method of% inherited% if the Android component), but the method is not accessible for my class
, since it is internal and not class
, and my protected
is in another class
.
Questions?
- Despite knowing that
package
attributes and methods are only accessible for members of the sameinternal
Java, I would like to know if there are any way to access these methods from apackage
of a otherclass
? - And optionally, if there is any other way to overwrite native components of Android, who can avoid this kind of problem?
Example of what I'm trying to do:
public class MeuAbsListView extends AdapterView<ListAdapter>{
public MeuAbsListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void meuMetodoDisparadoPeloMeuEvento(){
// faz seu comportamento custumizado ...
// e tem esse metodo 'rememberSyncState' do 'AdapterView' que preciso chamar
// só que ele é internal e não tenho acesso a ele,
// já no AbsListView nativo é possivel pois ele é do mesmo package do AdapterView
rememberSyncState();
}
}
In the Android AdapterView font method is declared as follows:
void rememberSyncState() {
// codigo do rememberSyncState ...
}