1

I want to add a new tab with button.I'm not taking an error but my app has stopped in emulator.Where is my error?Thank you for your your all helps.Note:My English is bad so sorry.If you have not a code or an idea with about subject you don't write pls.

private Button Add_Tab_Button;
int counter=0,counter2;
String[] Strings={
    "Section "+counter,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Add_Tab_Button=(Button) findViewById(R.id.Add_Tab_Button);
    final String[] Strings2 = new String[Strings.length+1];

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    Add_Tab_Button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            int array_size=Strings.length+1;
            for(; counter <array_size ; counter++)
Strings2[counter] = Strings[counter];
counter2=counter+1;
Strings2[counter2]="Section "+counter2;
        }
    });
    // Setup spinner
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    spinner.setAdapter(new MyAdapter(
            toolbar.getContext(),
            Strings2));

This is my event log:

19:51   Executing tasks: [:app:assembleDebug]
19:51   Gradle build finished in 13s 257ms
19:52   Emulator: Process finished with exit code 0

0 Answers0