2013-05-06 3 views
0

나는 안드로이드에서 새롭고 내가 그리드 뷰에서 이미지를 클릭 할 때 구현 한 그리드 뷰에 대해 작업하고 있습니다. 유형의 변수 "경로"에 이미지의 경로가 있습니다. 문자열은 ie /mnt/sdcard/me.jpg와 같습니다. 이미지의 이름 즉 "me.jpg"를 가져올 수 있으며 이미지의 날짜는이 목적을위한 함수 나 코드를 친절하게 말해줍니다. 코드는 경로의 아이디어를 제공하는이미지의 이름과 날짜를 가져옵니다

gridview.setOnItemLongClickListener(new OnItemLongClickListener() { 

     public boolean onItemLongClick(AdapterView<?> parent, View view, 
       int position, long id) { 
      path = (String)parent.getItemAtPosition(position); 
      /*Toast.makeText(getApplicationContext(), 
        path, 
        Toast.LENGTH_LONG).show();*/ 

      return false; 
     } 

답변

0
구글에

첫번째 검색 만 질문을 게시 .... 내가 갔었어요 정말 가혹한

File file = new File(path); 
String name = file.getName(); //here you get the name of the image 

Date lastModDate = new Date(file.lastModified()); // here you get the creation or last modified date of the file 
Log.i("File last modified @ : "+ lastModDate.toString()); 
+0

색조는 많이 떨어졌지만 잘못된 방향으로 가고 있었고 마지막 행에는 오류가 하나 더 있습니다. 회신을 위해 thnks를 찾으십시오. – user2350640

+0

로그 유형의 메소드 i (String, String)는 인수 (String) – user2350640

+0

Thnkx에는 적용되지 않지만 토스트를 통해 날짜를 표시 할 수있는 LOG.i()의 목적은 – user2350640

관련 문제