java - How to add dynamicaly TableRow inside a TableLayout in Android using .xml? -


I have trouble connecting rows with textView inside table layout.

I have a table_row .xml, where I define my tableware and the XML of its text view.

table_row xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; TableRow xmlns: android = "http://schemas.android.com/apk/res/android" Android: layout_width = "match_parent" Android: layout_height = "match_parent" & gt; Android: layout_height = "wrap_content" android: layout_weight = "2" android: text = "@ string / food_label" Android: textAppearance = "Android: Android: ATR / Text Appointments Small" /> Android: Android: layout_height = "wrap_content" Android: layout_weight = "1" Android: text = "@ string / kcal_labal" Android: text apparatus = "Android:? Android: ATR / Text Appointments Small" /> & Lt; / TableRow & gt;  

Here's what I do:

Within the class where I want to increase it. I define

  LayoutInflater inflater = (LayoutInflater) getSystemService (Context.LAYOUT_INFLATER_SERVICE); Personal Table Layout Tablerology = (Table Layout) Find VVBIID (RID tableLayout1); See tr = inflater.inflate (R.layout.table_row_conology, tap, incorrect); // Here I get an error; TableChronology.addView (tr);  

Here's the logcat:

  Fatal exception: main process: com.example.appscan5, PID: 31647 at java.lang.NullPointerException com.example Android for Android Click $ 2.8 for Android on View.View $ PerformClick.run (see .Java 18422) android.view.View.performClick (see .38.on.) (Today. Java: 66). Android.O.O.Lopper on Android.Handler.Depap Message (handler.java: 95) Lope (Looper Zvidor 36) Android. App Java.lang.reflect.Method.invoke Native (Native Method) on activateTrade.mine (Activity th. Java: 5017) at java.lang.reflect.Method.invoke (method.java) 15 com.android.internal.os. ZygoteInit $ MethodAndArgsCaller.run (Geogitinized. Java: 79) at com.android.internal.os.zygoteInit.main (Geogotinet.Java article 9 5) on Dalvik.system.NativeStart.main (Basic method)  < / Pre> 

If anybody is interested in it then my problem has been fixed.

I used:

  Personal LayoutInflat Flatter; See tr = inflater.inflate (R.layout.table_row_conology, tap); Instead of  

:

  LayoutInflator Inflator = (Layout Inflator) getSystemService (Reference. LAOUT_INFLATER_SERVICE);  

Below is the code:

  Private LayoutsInflator Inflighter; See tr = inflater.inflate (R.layout.table_row_conology, tap); TABLE LAYOUT Look for tablecronology = (table layout) VVBIID (RIDMentable); TableChronology.addView (tr);  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -