Friday, 15 May 2015

change android layout height when click on it -


I have a layout that has many linear layouts. I want to click on the child's layout, Match with father. I tried this code, but it does not extend the layout when clicking on it:

MainActivity.java:

  public class MainActivity ActionBarActivity Expanded {@Override Protected void onCreate (Bundle SavedInstanceState) {super.onCreate (Saved InstantState); Layout Inflight Inflator = (Layout Influenza) getSystemService (References LAOUT_INFLATER_SERVICE); Rainier layout default = (linear timer) inflater.inflate (R.layout.activity_main, null); {See custom = infilator. In flat (r.lay.ro, empty) for (int i = 0; i & lt; 1; i ++); TextView TV = (TextView) custom.findViewById (R.id.text); Tv.setText ("custom view" + i); Parent.addView (custom); } SetContentView (parent); See row = inflator diaflet (r.layout.in, blank); Find the last linear RO = (linear timepiece) VVBIID (R. LayOut.ro); Row.setOnClickListener (see the new OnClickListener () {@Override Public Zero click on (see V) {// TODO auto generated method stub ro.getLayoutParams (. Height = 100;}}); }  

and activity_main.xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Orientation = "vertical" & gt; & Lt; / LinearLayout & gt;  

and row.xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "30dp" Android: Orientation = "horizontal" & gt; & Lt; LinearLayout Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Orientation = "horizontal" & gt; & Lt; ImageView Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: src = "@drawable / ic_luncher" /> & Lt; TextView Android: id = "@ + id / text" Android: layout_width = "fill_parent" android: layout_height = "wrap_content" /> & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;  

try this:

  @override secured zero On Crate (Bundle Saved Instantstate) {Super. Contents (Saved Instance State); Layout Inflight Inflator = (Layout Influenza) getSystemService (References LAOUT_INFLATER_SERVICE); Rainier layout default = (linear timer) inflater.inflate (R.layout.activity_main, null); {See custom = infilator. In flat (r.lay.ro, empty) for (int i = 0; i & lt; 1; i ++); Custom.setTag (i); TextView TV = (TextView) custom.findViewById (R.id.text); Tv.setText ("custom view" + i); Parent.addView (custom); } SetContentView (parent); (See line = searchwebtag (i) for (int i = 0; i & lt; 1; i ++); Row.setOnClickListener (see the new OnClickListener () {@Override Public Zero click on (see V) {// TODO auto generated method stub ro.getLayoutParams (. Height = 100;}}); }}  

Note: I have not tested it. Please solve the small errors, if any


No comments:

Post a Comment