⑴ 商android中购物车用什么框架做的
Http/REST 请求:如果是严谨的REST API , Retrofit 会非常好用!各种 annotation 用起来省事又省心!唯独不好的地方是很多时候我们的接口不是完全的 REST 结构,同时需要针对每个 request 做单独的处理,这时候 Retrofit 就显得有些尴尬了。这时候我会用 volley,volley 的请求自定义和管理支持很好。
异步网络请求处理:是否曾经被网络请求的各种异常情况弄得焦头烂额?直到用到了 RoboSpice,事情变得简单许多。对网络请求的再次封装,将请求的各种结果回调变得简便,同时对 Retrofit , Okhttp,Ormlite 等支持都非常完善了,有了它,生活更 easy 了。
JSON解析:最通用的是 Gson ,用起来也很方便,但从效率上来讲 Gson 不是最快的, FastJson 和 Jackson 各有优势(具体分析参见这里:http //www cnblogs com/windlaughing/p/3241776.html)
数据库:ormLite和greenDao都挺好的。
⑵ android 添加到购物车怎么实现
Android购物车的实现可以使用数据库的方法,把加入的物品信息插入到数据库中,点击查看购物车时,查询数据库购物车的信息即可
⑶ 如何实现购物车功能 android 博客
你先要把这个界面布局给弄好,图片、文字、价格等都是从服务器获取的,然后用baseadapter适配器填充到listview中,最后进行相应的控件的事件处理就好了。
⑷ android手机购物车的界面如何设计求源代码
android手机购物车的界面如何设
肯定比较多,了解分析
大
⑸ 求一个 Android demo,类似这种的dialog,但要在购物车下面,不能覆盖购物车,谢谢
我感觉你用expandablelistview比较好吧,商店是父类,商店下面的商品是子类,你可以试下
⑹ android商城购物车悬浮多个页面之上怎么实现
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
// 悬浮所有页面之上
lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
// 失去焦点
lp.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
| LayoutParams.FLAG_NOT_FOCUSABLE;
TextView tv = new TextView(this);
tv.setText("我是不是你最疼爱的人,你为什么不说话,握住是你冰冷的手动也不动让我好难过");
tv.setBackgroundColor(Color.WHITE);
wm.addView(tv, lp);
}
}
⑺ android 淘宝APP购物车的列表是怎么做的
有很多种方法实现的
可用ScrollView或者ListView
⑻ 关于android的购物车功能是怎么实现的
主要代码如下: 是主要代码,
actvity中的代码:
public class ShoppingCartActivity extends BaseActivity {
private List<Test> data;
private ListView mListView;
private ShoppingCartAdapter adapter;
private RelativeLayout rlRefresh;
private TextView tvRefresh;
private ProgressBar barRefresh;
private LinearLayout clear;
private CheckBox checkBox_select_all;
private CheckBox checkBox_add;
private TextView integral_sum;
private int sum = 0;
private int[] sumIntegral;
private Context context;
@
protected void onCreate(Bundle bundle) {
// TODO Auto-generated method stub
super.onCreate(bundle);
setContentView(R.layout.activity_shopping_cart);
initView();
}
private void initView() {
context = this;
showpage = 1;
isPermitFlag = true;
data = new ArrayList<Test>();
// 测试数据
data.add(new Test("id", "color", "type", "100"));
data.add(new Test("id", "color", "type", "200"));
data.add(new Test("id", "color", "type", "300"));
adapter = new ShoppingCartAdapter(context, handler, data);
sumIntegral = new int[data.size() + 1];
checkBox_add = (CheckBox) findViewById(R.id.checkbox_add);
integral_sum = (TextView) findViewById(R.id.integral_sum);
clear = (LinearLayout) findViewById(R.id.clear);
clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
data.clear();
adapter.notifyDataSetChanged();
integral_sum.setText(0 + "");
checkBox_select_all.setChecked(false);
checkBox_add.setClickable(false);
}
});
cted.entrySet().iterator();
for (int i = 0; i < data.size(); i++) {
int num = data.get(i).getNum();
int integral = Integer.valueOf(data.get(i).getIntegral());
nums.add(num);
});
<CheckBox
android:layout_width="12dp"
android:layout_height="12dp"
android:background="@drawable/clear" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="清空购物车"
android:textColor="#b61d1d"
android:textSize="@dimen/small_size" />
</LinearLayout>
</LinearLayout>
<CheckBox
android:id="@+id/checkbox_add"
style="@style/CustomCheckboxTheme2"
android:layout_width="wrap_content"
android:clickable="false"
android:layout_height="wrap_content" />
Adaper中的代码:
public class ShoppingCartAdapter extends BaseAdapter {
private Context context;
private List<Test> loans;
private LayoutInflater inflater;
private static HashMap<Integer, Boolean> isSelected;
private static HashMap<Integer, Integer> numbers;
private Handler handler;
int num;// 商品数量
static class ViewHolder { // 自定义控件集合
public CheckBox ck_select;
public ImageView pic_goods;
public TextView id_goods;
public TextView color_goods;
public TextView type_goods;
public TextView integral_goods;
public AddMinusWidget add_minus;
public LinearLayout layout;
public TextView number;
public Button minus;
public Button plus;
}
/**
* 实例化Adapter
*
* @param context
* @param data
*/
public ShoppingCartAdapter(Context context, Handler handler, List<Test> data) {
this.context = context;
this.inflater = LayoutInflater.from(context);
this.loans = data;
this.handler = handler;
isSelected = new HashMap<Integer, Boolean>();
numbers = new HashMap<Integer, Integer>();
initDate();
}
private void initDate() {
for (int i = 0; i < loans.size(); i++) {
getIsSelected().put(i, false);
getNumbers().put(i, 1);
}
}
@Override
public int getCount() {
return loans.size();
}
@Override
public Object getItem(int position) {
return loans.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
/**
* 计算选中商品的积分
*
* @return 返回需要付费的总积分
*/
private float getTotalPrice() {
Test bean = null;
float totalPrice = 0;
for (int i = 0; i < loans.size(); i++) {
bean = loans.get(i);
if (ShoppingCartAdapter.getIsSelected().get(i)) {
totalPrice += bean.getNum()
* Integer.valueOf(bean.getIntegral());
}
}
return totalPrice;
}
public static HashMap<Integer, Boolean> getIsSelected() {
return isSelected;
}
public static void setIsSelected(HashMap<Integer, Boolean> isSelected) {
ShoppingCartAdapter.isSelected = isSelected;
}
public static HashMap<Integer, Integer> getNumbers() {
return numbers;
}
public static void setNumbers(HashMap<Integer, Integer> numbers) {
ShoppingCartAdapter.numbers = numbers;
}
实体类
package com.autoserve.net33.model;
public class Test {
@Override
public String toString() {
return "test [id=" + id + ", color=" + color
+ ", type=" + type + ", integral=" + integral + "]";
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getIntegral() {
return integral;
}
public void setIntegral(String integral) {
this.integral = integral;
}
private String id;
private String color;
private String type;
private String integral;
private int num;//商品数量
private int sumIntegral;
private boolean isChoosed; //商品是否在购物车中被选中
public Test(String id, String color, String type, String integral) {
super();
this.id = id;
this.color = color;
this.type = type;
this.integral = integral;
}
public Test() {
super();
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getSumIntegral() {
return sumIntegral;
}
public void setSumIntegral(int sumIntegral) {
this.sumIntegral = sumIntegral;
}
public boolean isChoosed() {
return isChoosed;
}
public void setChoosed(boolean isChoosed) {
this.isChoosed = isChoosed;
}
}
⑼ android仿淘宝购物车 如何实现
这个问题可以使用代理解决,当你能理解代理业就可以搞定了。
具体代码没有,你可以去网上找代理代码,特别类似苹果代码的那种代理。
⑽ 求java购物车例子。要用框架struts+hibernate+spring
java教程购物车Struts Hibernate实现shopcart
全部代码在
http://www.java125.cn/article.asp?id=1038
原理:利用会话保持用户一次购物操作的购买记录,当用户点击“结帐”后将保存在session中的hashmap容器中的信息insert到DB中,完成一次购物操作。
模块所需要配置文件:hibernate.cfg.xml ,TableGoods.hbm.xml ,struts-config.xml
模块对应的jsp有:index.jsp(商品信息一览页面),buy.jsp(购买操作后的商品清单页面)
模块对应的action有:IndexAction (实现对DB中的商品表信息结果集的遍历,并转向对应的index.jsp)
ListAction (将JSP上的商品信息存入hashmap容器,并转向对应的buy.jsp)
UpdateAction (对buy.jsp页面上的商品数量修改的业务逻辑处理)
DeleteAction (对buy.jsp页面上的商品列表信息的业务逻辑处理)
模块所需的相关Java容器选择:存储商品id,sum,price,name,allprices信息用hashmap,主要是考虑到其key重复后可以覆盖上次的value记录。存储点击商品后的商品id用list容器,主要考虑到list是有序并可以重复的特点,用其可以跟踪用户多次点击相同商品的操作,并对商品的数量进行相应的增加。
模块主要Action类如下:
IndexAction:
public class IndexAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
//查找商品表中的所有商品信息
GoodsDAO = new GoodsDAO();
List list = .find();
request.setAttribute("lister",list);
return mapping.findForward("a");
}
}
ListAction:
public class ListAction extends Action {
// 将hashmap中value转到list中
public static List getList(HashMap hs) {
List list = new ArrayList();
Iterator itr = hs.keySet().iterator();
while (itr.hasNext()) {
list.add(hs.get(itr.next()));
}
return list;
}
//优化后的getList方法
public static List getList(HashMap hs) {
return new ArrayList(hs.values());
}
全部代码在
http://www.java125.cn/article.asp?id=1038