I want to display even numbers from 0 to 50 in a text view, when button is clicked.
package com.example.a206_multithreading_assignment;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.TextView;public class MainActivity extends AppCompatActivity { TextView even; Button result; int[] numbers = new int[50]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); even = (TextView)findViewById(R.id.even); result = (Button)findViewById(R.id.result); result.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (int j=0 ; j<50 ; j++) { if (j%2 == 0) { even.setText(numbers[j]); } } } }); }}
Here is my code. My app got crash at run time.
I searched alot but find information about string arrays not related to integer arrays.I will be thankful, If my issue got resolved.