SoFunction
Updated on 2025-04-07

Android realizes the detailed explanation and examples of all pictures in the mobile phone

Android realizes the detailed explanation and examples of all pictures in the mobile phone

Implementation code:

public class MainActivity extends Activity { 

//View picture button  private Button look; 
  private Button add; 
//Show the list of the image name  ListView show_list; 
  ArrayList names = null; 
  ArrayList descs= null; 
  ArrayList fileNames = null; 
  @Override 
  protected void onCreate(Bundle savedInstanceState) { 
    (savedInstanceState); 
    setContentView(.activity_main); 
    look = (Button) findViewById(); 
    add = (Button) findViewById(); 
    show_list = (ListView) findViewById(.show_list); 
    (new () { 
      @Override 
      public void onClick(View view) { 
        names = new ArrayList(); 
        descs = new ArrayList(); 
        fileNames = new ArrayList(); 
        Cursor cursor = getContentResolver().query( 
            .EXTERNAL_CONTENT_URI, null, null, null, null); 
        while (()) { 
          //Get the name of the image          String name = ((.DISPLAY_NAME)); 
          //Get the image generation date          byte[] data = (()); 
          //Get detailed information of the picture          String desc = (()); 
          (name); 
          (desc); 
          (new String(data, 0,  - 1)); 
        } 
        List<Map<String, Object>> listItems = new ArrayList<>(); 
        for (int i = 0; i < (); i++) { 
          Map<String, Object> map = new HashMap<>(); 
          ("name", (i)); 
          ("desc", (i)); 
          (map); 
        } 
        //Set adapter        SimpleAdapter adapter = new SimpleAdapter(, listItems, 
            , new String[]{"name", "desc"}, new int[]{, }); 
 
        show_list.setAdapter(adapter); 
      } 
    }); 
 
    ///list click event  show_list.setOnItemClickListener(new () { 
    @Override 
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { 
      View viewDiag = getLayoutInflater().inflate(,null); 
      ImageView image = (ImageView)(); 
      (((String) (i))); 
      new ().setView(viewDiag) 
          .setPositiveButton("Sure",null).show(); 
    } 
  }); 
  } 
} 

XML:

<!--Obtain mobile phone memory card permissions-->
<uses-permission android:name=".READ_EXTERNAL_STORAGE"/>

Thank you for reading, I hope it can help you. Thank you for your support for this site!