-
-
Save anonymous/1169892 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| *此為 想用 自定義格式(class introduce )陣列 來儲存參數 結果模擬器強制結束 log檔也沒有設何錯誤資訊 | |
| */ | |
| package com.main; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import org.apache.http.HttpResponse; | |
| import org.apache.http.NameValuePair; | |
| import org.apache.http.client.entity.UrlEncodedFormEntity; | |
| import org.apache.http.client.methods.HttpPost; | |
| import org.apache.http.impl.client.DefaultHttpClient; | |
| import org.apache.http.message.BasicNameValuePair; | |
| import org.apache.http.protocol.HTTP; | |
| import org.apache.http.util.EntityUtils; | |
| import org.json.JSONArray; | |
| import org.json.JSONException; | |
| import org.json.JSONObject; | |
| import android.app.Activity; | |
| import android.graphics.Bitmap; | |
| import android.os.Bundle; | |
| import android.widget.ImageView; | |
| import android.widget.TextView; | |
| public class Main extends Activity { | |
| /** Called when the activity is first created. */ | |
| private TextView mTextView1; | |
| private ImageView mImageView1; | |
| private String a = new String(); | |
| introduce[] result = new introduce[10]; // 宣告我自定義的 class 格式 | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.main); | |
| mTextView1 = (TextView) findViewById(R.id.mTextView1); | |
| mImageView1 = (ImageView) findViewById(R.id.imageView1); | |
| result[1].set_g_Id("1");//設定值 | |
| a = result[1].get_g_Id(); //取得值 | |
| mTextView1.setText(a); //顯示在TextView上 | |
| //mImageView1.setImageBitmap(bm); | |
| } | |
| } | |
| /* | |
| 但改成非陣列就OK 這是我哪裡觀念有錯嗎? android不能使用自定義格式的陣列? 位址的關係? | |
| introduce result = new introduce(); | |
| result.set_g_Id("1"); //設定值 | |
| a = result.get_g_Id(); //取得值 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| *此為我自定義的格式 introduce.java | |
| */ | |
| package com.main; | |
| public class introduce { | |
| public String s_id; | |
| private String s_name; | |
| private String s_longitude; | |
| private String s_latitude; | |
| private String s_introduction; | |
| private String s_photo; | |
| private String g_id ; | |
| private String g_name; | |
| private String g_price; | |
| private String g_calorie; | |
| private int i; | |
| public int get_i() { | |
| return i; | |
| } | |
| public void set_i(int i) { | |
| this.i = i; | |
| } | |
| public String get_s_Id() { | |
| return s_id; | |
| } | |
| public void set_s_Id(String s_id) { | |
| this.s_id = s_id; | |
| } | |
| public String get_s_Name() { | |
| return s_name; | |
| } | |
| public void set_s_Name(String s_nam) { | |
| s_name = s_nam; | |
| } | |
| public String get_s_Longitude() { | |
| return s_longitude; | |
| } | |
| public void set_s_Longitude(String s_longitude) { | |
| this.s_longitude = s_longitude; | |
| } | |
| public String get_s_Latitude() { | |
| return s_latitude; | |
| } | |
| public void set_s_Latitude(String s_latitude) { | |
| this.s_latitude = s_latitude; | |
| } | |
| public String get_s_Introduction() { | |
| return s_introduction; | |
| } | |
| public void set_s_Introduction(String s_introduction) { | |
| this.s_introduction = s_introduction; | |
| } | |
| public String get_s_Photo() { | |
| return s_photo; | |
| } | |
| public void set_s_Photo(String s_photo) { | |
| this.s_photo = s_photo; | |
| } | |
| public String get_g_Id() { | |
| return g_id; | |
| } | |
| public void set_g_Id(String g_id) { | |
| this.g_id = g_id; | |
| } | |
| public String get_g_Name() { | |
| return g_name; | |
| } | |
| public void set_g_Name(String g_name) { | |
| this.g_name = g_name; | |
| } | |
| public String get_g_Price() { | |
| return g_price; | |
| } | |
| public void set_g_Price(String g_price) { | |
| this.g_price = g_price; | |
| } | |
| public String get_g_Calorie() { | |
| return g_calorie; | |
| } | |
| public void set_g_Calorie(String g_calorie) { | |
| this.g_calorie = g_calorie; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment