- Beranda
- Komunitas
- Tech
- Programmer Forum
[HELP] Programming Android dan Para Suhu Please Help Me
TS
apatar1111
[HELP] Programming Android dan Para Suhu Please Help Me
Gan Ane Perlu Bantuan Nih Ane lagi Buat Program Sederhana Buat Skripsi Ane Gan , masalahnya setelah retriving data terus ndak bisa asuk database nya gan help me gan !!!! di bawah ini Skrip Program nya gan
dan ini script java nya gan
Spoiler for MainActivity.xxml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android: orientation="vertical" >
<Button
android:id="@+id/bBed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/bedsmall"
android:text="Bed" />
<Button
android:id="@+id/bBedside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/bedsidesmall"
android:text="Bedside" />
<Button
android:id="@+id/bChair"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/chairsmall"
android:text="Chair" />
<Button
android:id="@+id/bChest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/chestsmall"
android:text="Chest" />
<Button
android:id="@+id/bDressing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/dressingsmall"
android:text="Dresser" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android: orientation="vertical" >
<Button
android:id="@+id/bBed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/bedsmall"
android:text="Bed" />
<Button
android:id="@+id/bBedside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/bedsidesmall"
android:text="Bedside" />
<Button
android:id="@+id/bChair"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/chairsmall"
android:text="Chair" />
<Button
android:id="@+id/bChest"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/chestsmall"
android:text="Chest" />
<Button
android:id="@+id/bDressing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:drawableLeft="@drawable/dressingsmall"
android:text="Dresser" />
</LinearLayout>
Spoiler for Activity_Main_ListView.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android: orientation="vertical" >
<ListView
android:id="@+id/ListProduk"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/item_custom_listview" >
</ListView>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android: orientation="vertical" >
<ListView
android:id="@+id/ListProduk"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/item_custom_listview" >
</ListView>
</LinearLayout>
Spoiler for item_custom_listview.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android: orientation="horizontal"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/img_produk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android: orientation="vertical" >
<TextView
android:id="@+id/nama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android: orientation="horizontal"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/img_produk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android: orientation="vertical" >
<TextView
android:id="@+id/nama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
Spoiler for dialog_custom.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android: orientation="vertical" >
<ImageView
android:id="@+id/picDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="Nama Produk"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/idNamaMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="not available"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="Spesifikasi"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/idSpesifikasi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="not available"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/idOK"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OK" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android: orientation="vertical" >
<ImageView
android:id="@+id/picDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="Nama Produk"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/idNamaMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="not available"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="Spesifikasi"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/idSpesifikasi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:text="not available"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/idOK"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OK" />
</LinearLayout>
dan ini script java nya gan
Spoiler for MainActivity.java:
package com.rizkijati;
import com.rizkijati.R;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bbed = (Button) findViewById(R.id.bBed);
Button bbedside = (Button) findViewById(R.id.bBedside);
Button bchair =(Button) findViewById(R.id.bChair);
Button bchest=(Button) findViewById(R.id.bChest);
Button bdressing=(Button) findViewById(R.id.bDressing);
bbed.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bBed= new Intent(MainActivity.this, MenuActivity.class);
b.putString("jenis_produk", "1");
bBed.putExtras(b);
startActivity(bBed);
}
});
bbedside.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bBedside = new Intent(MainActivity.this, MenuActivity.class);
b.putString("jenis_produk", "2");
bBedside.putExtras(b);
startActivity(bBedside);
}
});
bchair.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bChair = new Intent(MainActivity.this,MenuActivity.class);
b.putString("jenis_produk", "3");
bChair.putExtras(b);
startActivity(bChair);
}
});
bchest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bChest = new Intent(MainActivity.this,MenuActivity.class);
b.putString("jenis_produk", "4");
bChest.putExtras(b);
startActivity(bChest);
}
});
bdressing.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bDressing = new Intent(MainActivity.this,MenuActivity.class);
b.putString("jenis_produk", "5");
bDressing.putExtras(b);
startActivity(bDressing);
}
});
}
}
import com.rizkijati.R;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bbed = (Button) findViewById(R.id.bBed);
Button bbedside = (Button) findViewById(R.id.bBedside);
Button bchair =(Button) findViewById(R.id.bChair);
Button bchest=(Button) findViewById(R.id.bChest);
Button bdressing=(Button) findViewById(R.id.bDressing);
bbed.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bBed= new Intent(MainActivity.this, MenuActivity.class);
b.putString("jenis_produk", "1");
bBed.putExtras(b);
startActivity(bBed);
}
});
bbedside.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bBedside = new Intent(MainActivity.this, MenuActivity.class);
b.putString("jenis_produk", "2");
bBedside.putExtras(b);
startActivity(bBedside);
}
});
bchair.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bChair = new Intent(MainActivity.this,MenuActivity.class);
b.putString("jenis_produk", "3");
bChair.putExtras(b);
startActivity(bChair);
}
});
bchest.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bChest = new Intent(MainActivity.this,MenuActivity.class);
b.putString("jenis_produk", "4");
bChest.putExtras(b);
startActivity(bChest);
}
});
bdressing.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
Intent bDressing = new Intent(MainActivity.this,MenuActivity.class);
b.putString("jenis_produk", "5");
bDressing.putExtras(b);
startActivity(bDressing);
}
});
}
}
Spoiler for MenuActivity.java:
package com.rizkijati;
import java.io.InputStream;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.rizkijati.AmbilData.JsonObjectResult;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
public class MenuActivity extends Activity {
EntitasProduk entitasproduk;
ArrayList<EntitasProduk> menu = new ArrayList<EntitasProduk>();
ListView lv;
String url = "http://rizkijatifurniture.com/skripsi/menu_service.php";
String urlpic = "http://rizkijatifurniture.com/skripsi/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_listview);
lv = (ListView) findViewById(R.id.ListProduk);
Bundle b = this.getIntent().getExtras();
if (b.containsKey("jenis_produk")) {
String jen = b.getString("jenis_produk");
Log.d("jen", jen);
AmbilData ambildata = new AmbilData();
ambildata.init(MenuActivity.this, jsresult, jen, url);
}
}
public JsonObjectResult jsresult = new JsonObjectResult() {
@Override
public void gotJsonObject(JSONObject jobject) {
// TODO Auto-generated method stub
try {
JSONArray arraytempat = jobject.getJSONArray("dataproduk");
for (int i = 0; i < arraytempat.length(); i++) {
entitasproduk = new EntitasProduk();
entitasproduk.setIDproduk(arraytempat.getJSONObject(i)
.getInt("idproduk"));
entitasproduk.setNamaProduk(arraytempat.getJSONObject(i)
.getString("namaproduk"));
entitasproduk.setSpesifikasiProduk(arraytempat
.getJSONObject(i).getString("spesifikasiproduk"));
entitasproduk.setPicProduk(arraytempat.getJSONObject(i)
.getString("picproduk"));
menu.add(entitasproduk);
}
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MenuBaseAdapter datatempat = new MenuBaseAdapter(MenuActivity.this,
menu);
lv.setAdapter(datatempat);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int p,
long arg3) {
// TODO Auto-generated method stub
String des = menu.get(p).getSpesifikasiProduk();
String nm = menu.get(p).getNamaProduk();
String pic = menu.get(p).getPicProduk();
tampilkandetail(nm, des, pic);
}
});
}
};
public void tampilkandetail(String nama, String desk, String pic) {
final Dialog d = new Dialog(this);
d.setTitle("detail");
d.setContentView(R.layout.dialog_custom);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.WRAP_CONTENT;
d.getWindow().setAttributes(lp);
ImageView gb = (ImageView) d.findViewById(R.id.picDialog);
TextView n = (TextView) d.findViewById(R.id.idNamaMenu);
TextView desc = (TextView) d.findViewById(R.id.idSpesifikasi);
Button bOk = (Button) d.findViewById(R.id.idOK);
n.setText(nama);
desc.setText(desk);
new DownloadImageTask(gb).execute(urlpic + pic);
bOk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
d.dismiss();
}
});
d.show();
}
public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
if (result != null) {
Bitmap bmp2 = Bitmap.createScaledBitmap(result, 72, 72, true);
bmImage.setImageBitmap(bmp2);
}
}
}
}
import java.io.InputStream;
import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.rizkijati.AmbilData.JsonObjectResult;
import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.Dialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
public class MenuActivity extends Activity {
EntitasProduk entitasproduk;
ArrayList<EntitasProduk> menu = new ArrayList<EntitasProduk>();
ListView lv;
String url = "http://rizkijatifurniture.com/skripsi/menu_service.php";
String urlpic = "http://rizkijatifurniture.com/skripsi/";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_listview);
lv = (ListView) findViewById(R.id.ListProduk);
Bundle b = this.getIntent().getExtras();
if (b.containsKey("jenis_produk")) {
String jen = b.getString("jenis_produk");
Log.d("jen", jen);
AmbilData ambildata = new AmbilData();
ambildata.init(MenuActivity.this, jsresult, jen, url);
}
}
public JsonObjectResult jsresult = new JsonObjectResult() {
@Override
public void gotJsonObject(JSONObject jobject) {
// TODO Auto-generated method stub
try {
JSONArray arraytempat = jobject.getJSONArray("dataproduk");
for (int i = 0; i < arraytempat.length(); i++) {
entitasproduk = new EntitasProduk();
entitasproduk.setIDproduk(arraytempat.getJSONObject(i)
.getInt("idproduk"));
entitasproduk.setNamaProduk(arraytempat.getJSONObject(i)
.getString("namaproduk"));
entitasproduk.setSpesifikasiProduk(arraytempat
.getJSONObject(i).getString("spesifikasiproduk"));
entitasproduk.setPicProduk(arraytempat.getJSONObject(i)
.getString("picproduk"));
menu.add(entitasproduk);
}
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
MenuBaseAdapter datatempat = new MenuBaseAdapter(MenuActivity.this,
menu);
lv.setAdapter(datatempat);
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int p,
long arg3) {
// TODO Auto-generated method stub
String des = menu.get(p).getSpesifikasiProduk();
String nm = menu.get(p).getNamaProduk();
String pic = menu.get(p).getPicProduk();
tampilkandetail(nm, des, pic);
}
});
}
};
public void tampilkandetail(String nama, String desk, String pic) {
final Dialog d = new Dialog(this);
d.setTitle("detail");
d.setContentView(R.layout.dialog_custom);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(d.getWindow().getAttributes());
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.WRAP_CONTENT;
d.getWindow().setAttributes(lp);
ImageView gb = (ImageView) d.findViewById(R.id.picDialog);
TextView n = (TextView) d.findViewById(R.id.idNamaMenu);
TextView desc = (TextView) d.findViewById(R.id.idSpesifikasi);
Button bOk = (Button) d.findViewById(R.id.idOK);
n.setText(nama);
desc.setText(desk);
new DownloadImageTask(gb).execute(urlpic + pic);
bOk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
d.dismiss();
}
});
d.show();
}
public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
if (result != null) {
Bitmap bmp2 = Bitmap.createScaledBitmap(result, 72, 72, true);
bmImage.setImageBitmap(bmp2);
}
}
}
}
0
1.6K
Kutip
5
Balasan
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Urutan
Terbaru
Terlama
Guest
Tulis komentar menarik atau mention replykgpt untuk ngobrol seru
Komunitas Pilihan