|
|
|
Android สอบถามเรื่องการบันทึกตัวเลข ตรง rating ลง ฐานข้อมูล Mysql |
|
|
|
|
|
|
|
CustomAdaptor
Code (Android-Java)
package com.dedykuncoro.uthaitour.adapter;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RatingBar;
import android.widget.TextView;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.dedykuncoro.uthaitour.R;
import com.dedykuncoro.uthaitour.app.AppController;
import com.dedykuncoro.uthaitour.module.Jarak;
import java.util.List;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
/**
* Created by Kuncoro on 03/29/2016.
*/
public class CustomListAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
private List<Jarak> jarakItems;
ImageLoader imageLoader;
public CustomListAdapter(Activity activity, List<Jarak> jarakItems, String url) {
this.activity = activity;
this.jarakItems = jarakItems;
}
@Override
public int getCount() {
return jarakItems.size();
}
@Override
public Object getItem(int location) {
return jarakItems.get(location);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (inflater == null)
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.list_row, null);
if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbNail = (NetworkImageView) convertView
.findViewById(R.id.userPic);
TextView userName = (TextView) convertView.findViewById(R.id.userName);
userName.setSelected(true);
TextView userTim = (TextView) convertView.findViewById(R.id.userTim);
TextView userTell = (TextView) convertView.findViewById(R.id.userTell);
TextView userPrice = (TextView) convertView.findViewById(R.id.userPrice);
TextView userRating = (TextView) convertView.findViewById(R.id.userRating);
TextView jarak = (TextView) convertView.findViewById(R.id.jarak);
Jarak j = jarakItems.get(position);
thumbNail.setImageUrl(j.getGambar(), imageLoader);
userName.setText(j.getName());
userTim.setText(j.getTim());
userTell.setText(j.getTell());
userRating.setText(j.getRating());
userPrice.setText(j.getPrice());
jarak.setText(j.getJarak() + "กม.");
return convertView;
}
}
Detail.java
Code (Android-Java)
package com.dedykuncoro.uthaitour;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.content.Intent;
import android.net.Uri;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import com.bumptech.glide.Glide;
public class DetailTravel extends AppCompatActivity {
private Button button, btncalltravel, btngpsmaptravel;
private ImageView ShowImageTravel;
private TextView ShowNameTravel, ShowTimTravel, ShowDetailTravel, ShowRatingTravel;
RatingBar rb;
TextView va;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail_travel);
rb = (RatingBar) findViewById(R.id.rating);
va = (TextView) findViewById(R.id.textRating);
rb.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean b) {
va.setText("" + rating);
}
});
}
}
Activity_Detail.xml
Code (XML)
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="คะแนนความพึงพอใจ"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#757575"
android:textSize="16sp"
android:textStyle="bold|normal" />
<RatingBar
android:id="@+id/rating"
style="?android:attr/ratingBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="1"
android:layout_marginTop="20sp"
/>
<TextView
android:id="@+id/textRating"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#424242"
android:textSize="15dp"
android:layout_marginTop="35sp"
android:layout_gravity="right"
android:layout_marginRight="20sp"/>
</android.support.v7.widget.CardView>
Tag : Java, MySQL, Android, JAVA, Mobile
|
|
|
|
|
|
Date :
2017-03-06 00:39:36 |
By :
atikan5566 |
View :
1025 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้โค้ด ในส่วนไหนของโค้ดผมครับ
|
|
|
|
|
Date :
2017-03-06 12:42:49 |
By :
atikan5566 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอน Event ที่กด Rating ครับ
|
|
|
|
|
Date :
2017-03-06 13:59:01 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|