0

i am trying to make a note app when i click on my Open note activity it should create a button array but it do not show any buttons

thats the code to initial the button array:

package savovuksan.at.noteit;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import java.util.ArrayList;
import java.util.List;


public class NotizOeffnungsMenue extends Activity implements View.OnClickListener {


Button[] NoteListBtn ;
String[] NoteList ;





@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notiz_oeffnungs_menue);

        NoteListBtn = new Button[fileList().length];
        NoteList = fileList();

    for (int i = 0;i<fileList().length;i++)
    {


        NoteListBtn[i] = new Button(this);
        NoteListBtn[i].setText(NoteList[i]);
        NoteListBtn[i].setOnClickListener(this);

    }
Savo Vuksan
  • 115
  • 4

1 Answers1

0

You will need to add buttons in layout after you create them:

setContentView(R.layout.activity_notiz_oeffnungs_menue);
LinearLayout l1 = (LinearLayout)findViewById(R.id.layout1);

...

for (int i = 0;i<fileList().length;i++)
{
    NoteListBtn[i] = new Button(this);
    NoteListBtn[i].setText(NoteList[i]);
    NoteListBtn[i].setOnClickListener(this);
    l1.addView(NoteListBtn[i]);
}

Hope this helps.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124