I'm new to Android Studio programming and I'd like to know what is the substitute for code below.. I'm trying to iterate an infinite loop that has a nested one and it seem to not work. The application still crushes when it comes to that loop.
I also tried to use non-infinite loop without nesting another inside of it.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
while (state) {
int i = 0;
while (i < person[i].length) {
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
someTextView.setText(person[i].getName());
}
});
}
i++;
}
}
This Logcat below just represents the nested while loop without the onClickListener unlike shown in code.
2019-06-01 11:59:10.695 19529-19529/com.example.app2 I/Timeline: Timeline: Activity_launch_request id:com.example.app2 time:120814793
2019-06-01 11:59:10.771 19529-19543/com.example.app2 I/art: Enter while loop.
2019-06-01 11:59:10.789 19529-19543/com.example.app2 I/art: Enter while loop.
After entering while loop all I'm getting is a black screen on my device.
How do I use these loops within onCreate() method?