When list.size () == 0, all the processing in the extended for statement is passed through.
List<hogeDto> list = new ArrayList<>();
//list.size == 0
for(hogeDto dto : list){
Log.d("log",dto.getId());
}
Not called when getCount = 0. Be careful when you put list.size () == 0 in getCount.
If you set a number in textView, it will be mistaken for the resource ID. Since there is no object specified by resource ID as "3", I get an error. → If you convert to String and then setText, no error will occur.
int number = 3;
TextView view = findViewById(R.id.hoge);
view.setText(number);
① In onCreate (), fill the adapter with the empty List and draw the Layout. (2) When onResponse () is called, the List is filled with the data obtained from the API. Draw Layout again.
HogeActivity {
onCreate(){
① Define Shared Preferences(Used when acquiring API. Null measures.)
②List<hogeDto> list = new ArrayList<>();
③ Call the method that gets the data from the API and fills the List.
④ Pass List to adapter
}
//Method ③
API.getInstance.getHogePoint(){
onResponse(){
//Processing to pack data in List
//The adapter data has changed! Notification
adapter.notifyDataSetChanged();
}
}
}
If you use runnable, the error disappears.
/**
*adapter update process
*/
private Runnable adapterNotify = new Runnable() {
@Override
public void run() {
adapter.notifyDataSetChanged();
}
};
Recommended Posts