- Beranda
- Komunitas
- Tech
- Programmer Forum
[HELP] gan map saya ngga tampil ya?
TS
aero.smith
[HELP] gan map saya ngga tampil ya?
javanya gan
nih gan layoutnya
mohon bantuannya dong gan ane masih new bie
makasih
Spoiler for Java:
Code:
package irul.skripsi.test;
import java.text.DecimalFormat;
import java.util.List;
import irul.skripsi.test.mapservice.DrawRoute;
import irul.skripsi.test.mapservice.LocationResult;
import irul.skripsi.test.mapservice.MyLocation;
import irul.skripsi.test.mapservice.OnPointedListener;
import irul.skripsi.test.mapservice.LocationResult.LocationType;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.SupportMapFragment;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Intent;
import android.content.res.TypedArray;
import android.location.Location;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
//import android.widget.Toast;
public class Detail_objek extends FragmentActivity {
String fileid, filenama, filefasilitas, filebudget, filelongitude,
filelatitude, filegambar, filejarak;
String filegambar2, filegambar3, filegambar4, filegambar5;
TextView tnama, tfasilitas, tbudget;
int galleryItemBg;
Button btngps;
public ImageLoader imageLoader;
public ImageView gambar, gambar2, gambar3, gambar4, gambar5;
ProgressDialog pDialog;
public GalleryResourceAdapter galleryResourceAdapter;
public Gallery galleryResource;
public GalleryAdapter galleryAdapter;
public ImageView imageViewURL;
public Gallery gallery;
private GoogleMap mMap;
private LatLng userLocation;
Double destLatitude, destLongitude;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_objek);
//inisialisasi google map
initMap();
// menangkap file kiriman
Intent in = getIntent();
fileid = in.getStringExtra("id");
filenama = in.getStringExtra("nama");
filefasilitas = in.getStringExtra("fasilitas");
filebudget = in.getStringExtra("budget");
filejarak = in.getStringExtra("jarak");
filelongitude = in.getStringExtra("longitude");
filelatitude = in.getStringExtra("latitude");
filegambar = in.getStringExtra("gambar");
filegambar2 = in.getStringExtra("gambar2");
filegambar3 = in.getStringExtra("gambar3");
filegambar4 = in.getStringExtra("gambar4");
filegambar5 = in.getStringExtra("gambar5");
Log.d("log", "kiriman detail:" + fileid + "," + filenama + ","
+ filefasilitas + "," + filelatitude + "," + filelongitude
+ filegambar);
// gambar textnama textfasilitas textbudget btngps"
gambar = (ImageView) findViewById(R.id.gambar);
gambar2 = (ImageView) findViewById(R.id.gambar2);
gambar3 = (ImageView) findViewById(R.id.gambar3);
gambar4 = (ImageView) findViewById(R.id.gambar4);
gambar5 = (ImageView) findViewById(R.id.gambar5);
// ImageLoader class instance
imageLoader = new ImageLoader(getApplicationContext());
imageLoader.DisplayImage(filegambar, gambar);
/*
* imageLoader.DisplayImage(filegambar2, gambar2);
* imageLoader.DisplayImage(filegambar3, gambar3);
* imageLoader.DisplayImage(filegambar4, gambar4);
* imageLoader.DisplayImage(filegambar5, gambar5);
*/
Log.d("log", "kiriman2:" + gambar);
TypedArray typArray = obtainStyledAttributes(R.styleable.AndroidGallery);
galleryItemBg = typArray.getResourceId(
R.styleable.AndroidGallery_android_galleryItemBackground, 0);
/** GALLERY FETCH FROM URL **/
imageViewURL = (ImageView) findViewById(R.id.imageView02);
String[] imgUrl = { filegambar, filegambar2, filegambar3, filegambar4,
filegambar5 };
galleryAdapter = new GalleryAdapter(this, galleryItemBg, imgUrl);
gallery = (Gallery) findViewById(R.id.galleryViewUrl);
gallery.setAdapter(galleryAdapter);
gallery.setSelection(3);
gallery.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// imageViewURL.setImageBitmap(galleryAdapter.loadBitmap(position));
imageLoader.DisplayImage(galleryAdapter.getUrl(position),
imageViewURL);
}
});
imageViewURL.setImageBitmap(galleryAdapter.loadBitmap(3));
tnama = (TextView) findViewById(R.id.textnama);
tfasilitas = (TextView) findViewById(R.id.textfasilitas);
tbudget = (TextView) findViewById(R.id.textbudget);
new DownloadList().execute();
}
private class DownloadList extends AsyncTask<Void, Void, Void> {
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Detail_objek.this);
pDialog.setMessage("Tunggu Sebentar...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected Void doInBackground(Void... unused) {
destLatitude = Double.parseDouble(filelatitude);
destLongitude = Double.parseDouble(filelongitude);
return null;
}
protected void onPostExecute(Void unused) {
pDialog.dismiss();
runOnUiThread(new Runnable() {
public void run() {
tnama.setText(filenama);
tfasilitas.setText(filefasilitas);
tbudget.setText(filebudget);
}
});
addMarkerToMap(new LatLng(destLatitude, destLongitude), false);
searchLocation();
}
}
private void initMap() {
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
private void addMarkerToMap(LatLng point, boolean isDraggable) {
if (point == null) {
return;
}
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point, 15f));
mMap.addMarker(new MarkerOptions()
.position(point)
.draggable(isDraggable)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
}
private void doDrawFastestRoute(final double srcLatitude, final double srcLongitude,
double destLatitude, double destLongitude) {
DrawRoute route = new DrawRoute(srcLatitude, srcLongitude,
destLatitude, destLongitude);
route.applyTo(mMap, this, new OnPointedListener() {
@Override
public void OnDrawLine(List<Polyline> pointRoute, double distance) {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(srcLatitude, srcLongitude), 15f));
}
});
}
private void searchLocation() {
final ProgressDialog dialog = ProgressDialog.show(this, "",
"Searching Location");
try {
LocationResult locationResult = new LocationResult() {
@Override
public void gotLocation(final Location location,
LocationType type) {
if (location == null) {
Detail_objek.this.runOnUiThread(new Runnable() {
public void run() {
dialog.dismiss();
popUpMessage("Tidak dapat menemukan lokasi");
}
});
} else {
Detail_objek.this.runOnUiThread(new Runnable() {
public void run() {
dialog.dismiss();
if (mMap != null) {
userLocation = new LatLng(location
.getLatitude(), location
.getLongitude());
addMarkerToMap(userLocation, false);
doDrawFastestRoute(userLocation.latitude,
userLocation.longitude,
destLatitude, destLongitude);
}
}
});
}
}
};
MyLocation myLocation = new MyLocation();
myLocation.getLocation(this, locationResult);
} catch (Exception e) {
dialog.dismiss();
popUpMessage("Tidak dapat menemukan lokasi");
}
}
private void popUpMessage(String msg) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
}
nih gan layoutnya
Spoiler for detail_object.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android/:o/rientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_above="@+id/map"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android/:o/rientation="vertical"
android/:p/adding="@dimen/dimen_5dp"
android/:p/addingLeft="17.0dip"
android/:p/addingRight="17.0dip" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Place Information "
android:textColor="#000000"
android:textSize="@dimen/text_16sp"
android:textStyle="bold" />
<Gallery
android:id="@+id/galleryViewUrl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<com.loopj.android.image.SmartImageView
android:id="@+id/imageView02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<com.loopj.android.image.SmartImageView
android:id="@+id/gambar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/no"
android:visibility="gone" />
<ImageView
android:id="@+id/gambar2"
android:layout_width="wrap_content"
android:layout_height="200dip"
android:layout_gravity="center"
android:gravity="center"
android/:p/adding="@dimen/dimen_2dp"
android:src="@drawable/no"
android:visibility="gone" />
<ImageView
android:id="@+id/gambar3"
android:layout_width="wrap_content"
android:layout_height="200dip"
android:layout_gravity="center"
android:gravity="center"
android/:p/adding="@dimen/dimen_2dp"
android:src="@drawable/no"
android:visibility="gone" />
<ImageView
android:id="@+id/gambar4"
android:layout_width="wrap_content"
android:layout_height="200dip"
android:layout_gravity="center"
android:gravity="center"
android/:p/adding="@dimen/dimen_2dp"
android:src="@drawable/no"
android:visibility="gone" />
<ImageView
android:id="@+id/gambar5"
android:layout_width="wrap_content"
android:layout_height="200dip"
android:layout_gravity="center"
android:gravity="center"
android/:p/adding="@dimen/dimen_2dp"
android:src="@drawable/no"
android:visibility="gone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="@dimen/text_8sp" />
<TextView
android:id="@+id/textnama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android/:p/addingLeft="@dimen/dimen_5dp"
android:textColor="#000000"
android:textSize="@dimen/text_16sp"
android:typeface="sans" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="@dimen/text_8sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android/:p/addingLeft="@dimen/dimen_5dp"
android:text="Fasilitas :"
android:textColor="#000000"
android:textSize="@dimen/text_16sp"
android:typeface="sans" />
<TextView
android:id="@+id/textfasilitas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android/:p/addingLeft="@dimen/dimen_10dp"
android:textColor="#000000"
android:textSize="@dimen/text_16sp"
android:typeface="sans" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="@dimen/text_8sp" />
<TextView
android:id="@+id/textbudget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android/:p/addingLeft="@dimen/dimen_5dp"
android:textColor="#000000"
android:textSize="@dimen/text_16sp"
android:typeface="sans" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="@dimen/text_16sp" />
</LinearLayout>
</ScrollView>
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="200dp" />
</RelativeLayout>
mohon bantuannya dong gan ane masih new bie
makasih
Diubah oleh aero.smith 02-05-2015 06:19
0
959
Kutip
8
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