Today, try to use a little GridLayout, but when they use addView reported a mistake
Who knows what the problem is look at the help, the code is very simple as
GridLayout gridLayout = null;
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
gridLayout = (GridLayout) findViewById (R.layout.activity_main);
View view = View.inflate (this, R.layout.item, null);
ImageView image = (ImageView) view.findViewById (R.id.image);
image.setBackgroundResource (R.drawable.ic_launcher);
gridLayout.addView (view);
}
Configuration file as follows
xmlns: tools = "http://schemas.android.com/tools"
android: id = "@ + id/GridLayout1"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: paddingBottom = "@ dimen / activity_vertical_margin"
android: paddingLeft = "@ dimen / activity_horizontal_margin"
android: paddingRight = "@ dimen / activity_horizontal_margin"
android: paddingTop = "@ dimen / activity_vertical_margin"
android: rowCount = "4"
android: columnCount = "4"
>
Log information is as follows:

<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
gridLayout = (GridLayout) findViewById (R.layout.activity_main);
= "
gridLayout = (GridLayout) findViewById (R.id.GridLayout1);
Reply:
Well, I 2, thank you
No comments:
Post a Comment