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 - อยากให้ SimpleAdapter โชว์รูปที่อยู่ใน Server ด้วยครับ ติดปัญหาครับ ช่วยแนะนำด้วยครับ



 

Android - อยากให้ SimpleAdapter โชว์รูปที่อยู่ใน Server ด้วยครับ ติดปัญหาครับ ช่วยแนะนำด้วยครับ

 



Topic : 099247



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



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



คือ


activity_main.java

Code (Android-Java)
package com.test.android_listview_and_imageviewprojecturl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;

import android.util.Log;

import android.view.Menu;

import android.widget.ListView;
import android.widget.SimpleAdapter;

public class MainActivity extends Activity {


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

        // Permission StrictMode
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }

        SearchData();
        // Perform action on click


    }

    public void SearchData()
    {

        final ListView lisView1 = (ListView)findViewById(R.id.listView1);

        String url = "http://192.168.1.3/android/getPic.php";

        // Paste Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();

        try {
            JSONArray data = new JSONArray(getJSONUrl(url,params));

            final ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
            HashMap<String, String> map;

            for(int i = 0; i < data.length(); i++){
                JSONObject c = data.getJSONObject(i);

                map = new HashMap<String, String>();
                map.put("Id_shop", c.getString("Id_shop"));
                map.put("Date_Record", c.getString("Date_Record"));
                map.put("Shop_Record", c.getString("Shop_Record"));
                map.put("Title_Name", c.getString("Title_Name"));
                map.put("Detail_Product", c.getString("Detail_Product"));
                map.put("Price", c.getString("Price"));
                map.put("Name_Picture", c.getString("Name_Picture"));
                map.put("Path_Picture", c.getString("Path_Picture"));
                MyArrList.add(map);

            }



            SimpleAdapter sAdap;
            sAdap = new SimpleAdapter(MainActivity.this, MyArrList, R.layout.activity_column,
                    new String[] {"Id_shop", "Title_Name", "Path_Picture"}, new int[] {R.id.ColId_shop, R.id.Title_Name, R.id.ColPath_Picture});
            lisView1.setAdapter(sAdap);



        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


    public String getJSONUrl(String url,List<NameValuePair> params) {
        StringBuilder str = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        try {
            httpPost.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
            HttpResponse response = client.execute(httpPost);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) { // Download OK
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content,"UTF-8"));
                String line;
                while ((line = reader.readLine()) != null) {
                    str.append(line);
                }
            } else {
                Log.e("Log", "Failed to download file..");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str.toString();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}


activity_main.java
Code (Android-Java)
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
             android:id="@+id/tableLayout1"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent">



    <View
            android:layout_height="1dip"
            android:background="#CCCCCC" />

    <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.1">

        <ListView
                android:id="@+id/listView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
        </ListView>

    </LinearLayout>

    <View
            android:layout_height="1dip"
            android:background="#CCCCCC" />

    <LinearLayout
            android:id="@+id/LinearLayout1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="5dip" >

        <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="By.. ThaiCreate.Com" />

    </LinearLayout>

</TableLayout>


activity_column.xml

Code (Android-Java)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/linearLayout1"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent" >

    <TextView
            android:id="@+id/ColId_shop"
            android:layout_width="20dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.2"
            android:text="CustomerID"
            android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
            android:id="@+id/Title_Name"
            android:layout_width="30dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.0"
            android:text="Name"
            android:textAppearance="?android:attr/textAppearanceSmall" />

    <TextView
            android:id="@+id/ColPath_Picture"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Email"
            android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>




re

ผลลัพธ์ตามรูปครับ แต่ที่ผมอยากได้คือ ให้ คอลัมน์ที่ 3 เป็นรูปที่อยู่บน Server ของในเครื่องผมอ่าครับรบกวนช่วยด้วยครับ



Tag : Mobile, MySQL, Android, Tablets







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-08-18 05:11:33 By : Digitalhong View : 1312 Reply : 4
 

 

No. 1



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

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

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

เปลี่ยนไปใช้ CustomAdapter ครับ เข้าไปอ่านในบทความได้ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-08-18 07:39:49 By : mr.win
 


 

No. 2



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



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

ตอบความคิดเห็นที่ : 1 เขียนโดย : mr.win เมื่อวันที่ 2013-08-18 07:39:49
รายละเอียดของการตอบ ::
พี่วินครับ ไม่มีอ่ะครับ เพราะ จากภาพผมต้องการ ใน show picture จาก Mysql อ่ะครับ

ช่วยด้วยครับพี่ ผมติดปัญหาไปต่อไม่ได้

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-08-18 13:35:40 By : Digitalhong
 

 

No. 3



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

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

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



Android JSON Retrieving Data from URL Web Server (PHP MySQL and JSON)

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-08-18 14:33:30 By : mr.win
 


 

No. 4



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



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

ตอบความคิดเห็นที่ : 3 เขียนโดย : mr.win เมื่อวันที่ 2013-08-18 14:33:30
รายละเอียดของการตอบ ::
ขอบคุณมากครับพี่วิน

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-08-18 18:17:35 By : Digitalhong
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android - อยากให้ SimpleAdapter โชว์รูปที่อยู่ใน Server ด้วยครับ ติดปัญหาครับ ช่วยแนะนำด้วยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 03
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 อัตราราคา คลิกที่นี่