I am making an android application, which creates a dynamic interface, according to a string read from your preferences:
ScrollView sv = new ScrollView(this);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
TableLayout tl = new TableLayout(this);
TableRow[] tr = null;
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String Favs = SP.getString("Favs", "None");
String[] Genveje;
if (!Favs.equals("None"))
{
Genveje = Favs.split(";");
tr = new TableRow[Genveje.length];
for (int i = 0; i < Genveje.length; i++)
{
String BtnName = Genveje[i].split("@")[0];
String BtnPath = Genveje[i].split("@")[1];
Button btn = new Button(this);
btn.setText(BtnName);
btn.setTag(BtnPath);
btn.setOnClickListener(this);
btn.setOnLongClickListener(this);
tr[i].addView(btn);
.........
}
The problem is: when i try to do ANYTHING with tr[i] i get a NullPointerException, and i have no clue why.
Anyone with a suggestion?