[JAVA] [Android] Detailed notes

I have never passed the process in the extension for

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());
}

getView of adapter has never been called

Not called when getCount = 0. Be careful when you put list.size () == 0 in getCount.

I get a NotFound ResourceId error

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);

If you hit the API and fill the List with Activity, pass the List to the Adapter and new it, the List will be null.

① 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();
    }
  }
}

I get an error with 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

[Android] Detailed notes
[Android / Kotlin] Detailed notes 2
Notes in Android studio
Notes for Android application development beginners
Notes on calling Installer on Android App
Notes on Android (java) thread processing
Android view
JUnit 4 notes
java notes
Notes on creating android plugins for Unity
synchronized notes
Notes on getting Callback from Android text-to-speech function TextToSpeech