Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > [Android GridView Full Image] รบกวนด้วยครับ อยากถามเกี่ยวกับ Gridview ครับ



 

[Android GridView Full Image] รบกวนด้วยครับ อยากถามเกี่ยวกับ Gridview ครับ

 



Topic : 117278



โพสกระทู้ ( 2 )
บทความ ( 0 )



สถานะออฟไลน์




รบกวนด้วยครับ อยากถามเกี่ยวกับ Gridview ครับ คือผมได้ลอง ทำตาม source code จาก https://www.thaicreate.com/mobile/android-sdcard-imageview-sqlite.html

Code (Android-Java)
public class MainActivity extends Activity {

    List <String> ImageList;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /*** Get Images from SDCard ***/
        ImageList = getSD();

        // gridView1
        final  GridView gView1 = (GridView)findViewById(R.id.gridView1);

        gView1.setAdapter(new ImageAdapter(this,ImageList));


        // OnClick
        gView1.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v,
                                    int position, long id) {

                View layout = inflater.inflate(R.layout.custom_full_imagedialog,
                        (ViewGroup) findViewById(R.id.layout_root));
                ImageView image = (ImageView) layout.findViewById(R.id.fullimage);
                Toast.makeText(getApplicationContext(),
                        "Your selected : " + ImageList.get(position).toString(), Toast.LENGTH_SHORT).show();

            }
        });

    }

    private List <String> getSD()
    {
        List <String> it = new ArrayList <String>();
        File f = new  File(
            android.os.Environment.getExternalStorageDirectory()
                    + File.separator + Constance.PHOTO_ALBUM);
        File[] files = f.listFiles ();


        for (int i = 0; i <files.length; i++)
        {
            File  file = files[i];
            Log.d("Count",file.getPath());
            it.add (file.getPath());
        }
        return it;
    }

    public class ImageAdapter extends BaseAdapter
    {
        private Context context;
        private List <String> lis;

        public ImageAdapter(Context c, List <String> li)
        {
            // TODO Auto-generated method stub
            context = c;
            lis = li;
        }



        public int getCount() {
            // TODO Auto-generated method stub
            return lis.size();
        }

        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub

            LayoutInflater inflater = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);


            if (convertView == null) {
                convertView = inflater.inflate(R.layout.show_image, null);
            }

            TextView textView = (TextView) convertView.findViewById(R.id.textView1);
            String strPath = lis.get(position).toString();

            // Get File Name
            String fileName = strPath.substring( strPath.lastIndexOf('/')+1, strPath.length() );
            textView.setText(fileName);

            // Image Resource
            ImageView imageView = (ImageView) convertView.findViewById(R.id.imageView1);
            Bitmap bm = BitmapFactory.decodeFile(strPath);
            imageView.setImageBitmap(bm);

            return convertView;

        }


ตรงตัวแปร inflater บรรทัด 24 มันเป็นสีแดงครับ ไม่ทราบว่าผมทำผิดตรงไหนหรอครับ ผมทำใน Android Studio มันบอก cannot resolve method



Tag : Mobile, Android, Mobile









ประวัติการแก้ไข
2015-06-21 16:48:37
2015-06-21 16:49:20
2015-06-21 16:49:42
2015-06-21 16:50:42
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-06-21 16:45:55 By : yieldza View : 1221 Reply : 1
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ขอดู Error message ตอนที่ Build หน่อยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-06-22 10:55:58 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : [Android GridView Full Image] รบกวนด้วยครับ อยากถามเกี่ยวกับ Gridview ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่