Reputation:
I've currently got the following;
setupHideKeyboard( findViewById( R.id.login_layout ), this );
public void setupHideKeyboard( final View view, final Activity activity ) {
if ( !( view instanceof EditText ) ) {
view.setOnTouchListener( new View.OnTouchListener() {
// crashes on the above line
public boolean onTouch( View v, MotionEvent event ) {
hideSoftKeyboard( activity );
view.setFocusableInTouchMode( true );
view.requestFocus();
return false;
}
});
}
if ( view instanceof ViewGroup ) {
for ( int childView = 0; childView < ( ( ViewGroup) view ).getChildCount(); childView++ ) {
View innerView = ( ( ViewGroup ) view ).getChildAt( childView );
setupHideKeyboard( innerView, activity );
}
}
that is being used to set a on touch listener to hide the keyboard when a edittext is not pressed, this WORKS FINE on my HTC One M7, but crashes on my Samsung Galaxy Tab S 10.5.
The view for some reason is null on the tab s but fine on the m7. Any obvious idea why?
It's like it can't find the R.id.login_layout
do large xml have a different name to smaller ones?
Upvotes: 0
Views: 106
Reputation: 2295
Maybe there is a same layout file in your layout and layout-large/layout-xlarge folder. But login_layout is defined only in the layout folder file. So since the tablet would take the xml from layout-large/layout-xlarge, there is no problem with inflation, but it is not able to get the login_layout view from that layout file. Hence you are getting a crash.
Upvotes: 0