Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 18th, 2013  |  syntax: None  |  size: 3.58 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.***;
  2.  
  3. import org.json.JSONArray;
  4. import org.json.JSONException;
  5.  
  6. import android.app.Activity;
  7. import android.os.Bundle;
  8. import android.util.Log;
  9. import android.view.ViewGroup.LayoutParams;
  10. import android.widget.TableLayout;
  11. import android.widget.TableRow;
  12. import android.widget.TextView;
  13.  
  14. public class Tabelle extends Activity {
  15.  
  16. url= "***";
  17. JSONDownloader jdown;
  18. TableLayout tl;
  19.  
  20.  
  21. @Override
  22. public void onCreate(Bundle savedInstanceState){
  23.     super.onCreate(savedInstanceState);
  24.     setContentView(R.layout.activity_tabelle);
  25.     tl = (TableLayout) findViewById(R.id.tabelleLayout);
  26.     new JSONDownloader().execute(url);
  27. }
  28.  
  29. public void makeNewRow(JSONArray platzierung, int row) {
  30.     row++;
  31.     TableRow tr = new TableRow(this);
  32.     tr.setId(100+row);
  33.     tr.setLayoutParams(
  34.             new LayoutParams(
  35.                     LayoutParams.MATCH_PARENT,
  36.                     LayoutParams.WRAP_CONTENT)
  37.             );
  38.  
  39.     TextView platz = new TextView(this);
  40.     platz.setId(200+row);
  41.     platz.setText(row);
  42.     platz.setLayoutParams(
  43.             new TableRow.LayoutParams(
  44.                     0,
  45.                     LayoutParams.WRAP_CONTENT,
  46.                     1f)
  47.             );
  48.     tr.addView(platz);
  49.  
  50.     /**other textviews **/
  51.  
  52.     tl.addView(tr);
  53. }
  54.   }
  55.        
  56. 11-04 17:26:59.859: E/AndroidRuntime(5389): FATAL EXCEPTION: main
  57. 11-04 17:26:59.859: E/AndroidRuntime(5389): java.lang.NullPointerException
  58. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.content.ContextWrapper.getResources(ContextWrapper.java:81)
  59. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.view.View.<init>(View.java:3228)
  60. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.view.ViewGroup.<init>(ViewGroup.java:416)
  61. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.widget.LinearLayout.<init>(LinearLayout.java:168)
  62. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.widget.TableRow.<init>(TableRow.java:61)
  63. 11-04 17:26:59.859: E/AndroidRuntime(5389): at com.***.Tabelle.makeNewRow(Tabelle.java:51)
  64. 11-04 17:26:59.859: E/AndroidRuntime(5389): at com.***.Tabelle.showTable(Tabelle.java:37)
  65. 11-04 17:26:59.859: E/AndroidRuntime(5389): at com.***.JSONDownloader.onPostExecute(JSONDownloader.java:79)
  66. 11-04 17:26:59.859: E/AndroidRuntime(5389): at com.***.JSONDownloader.onPostExecute(JSONDownloader.java:1)
  67. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.os.AsyncTask.finish(AsyncTask.java:631)
  68. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.os.AsyncTask.access$600(AsyncTask.java:177)
  69. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
  70. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.os.Handler.dispatchMessage(Handler.java:99)
  71. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.os.Looper.loop(Looper.java:137)
  72. 11-04 17:26:59.859: E/AndroidRuntime(5389): at android.app.ActivityThread.main(ActivityThread.java:4931)
  73. 11-04 17:26:59.859: E/AndroidRuntime(5389): at java.lang.reflect.Method.invokeNative(Native Method)
  74. 11-04 17:26:59.859: E/AndroidRuntime(5389): at java.lang.reflect.Method.invoke(Method.java:511)
  75. 11-04 17:26:59.859: E/AndroidRuntime(5389): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
  76. 11-04 17:26:59.859: E/AndroidRuntime(5389): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
  77. 11-04 17:26:59.859: E/AndroidRuntime(5389):     at dalvik.system.NativeStart.main(Native Method)
  78.        
  79. @Override
  80. protected void onPostExecute (JSONArray jarray){
  81.    table=new Tabelle();
  82.    table.showTable(jarray);
  83. }
  84.        
  85. @Override
  86. protected void onPostExecute (JSONArray jarray){
  87.     Tabelle.this.showTable(jarray);
  88. }