@ -1,135 +0,0 @@
|
||||
package com.example.orangesale_04.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.example.orangesale_04.R;
|
||||
import com.example.orangesale_04.adapter.Adapter;
|
||||
import com.example.orangesale_04.entity.Product;
|
||||
import com.example.orangesale_04.fragment.SetDetailFragment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CategoryActivity extends Activity {
|
||||
public OnChangeListener onchangedListener;
|
||||
private List<Product> productList;
|
||||
private List<String> productCategory = new ArrayList<>();
|
||||
private ListView titleList;
|
||||
private Adapter adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.content_category);
|
||||
initData();
|
||||
init();
|
||||
SetDetailFragment fragment = new SetDetailFragment();
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
transaction.replace(R.id.category_detail, fragment);
|
||||
transaction.commit();
|
||||
titleList.setOnItemClickListener((parent, view, position, id) -> {
|
||||
adapter.setSelectedPosition(position);
|
||||
adapter.notifyDataSetInvalidated();
|
||||
if (onchangedListener != null) {
|
||||
onchangedListener.changeText(productList.get(position));
|
||||
}
|
||||
});
|
||||
/* titleList.setOnItemClickListener((parent, view, position, id) -> {
|
||||
adapter.setSelectedPosition(position);
|
||||
adapter.notifyDataSetInvalidated();
|
||||
if (onchangedListener != null) {
|
||||
onchangedListener.changeText(productList.get(position));
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void setOnChangeListener(OnChangeListener onChangeListener) {
|
||||
this.onchangedListener = onChangeListener;
|
||||
}
|
||||
|
||||
public interface OnChangeListener {
|
||||
void changeText(Product product);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initData() {
|
||||
productList = new ArrayList<>();
|
||||
productCategory.add("水果");
|
||||
productCategory.add("办公材料");
|
||||
productCategory.add("工艺品");
|
||||
productCategory.add("零食");
|
||||
productCategory.add("服装");
|
||||
productCategory.add("生活用品");
|
||||
productCategory.add("文具");
|
||||
productCategory.add("生鲜");
|
||||
productCategory.add("医药");
|
||||
Product product = new Product();
|
||||
product.setImageUrlId(R.drawable.juzi1);
|
||||
product.setProductName("橘子");
|
||||
product.setProductPrice(new BigDecimal("9.9"));
|
||||
Product product1 = new Product();
|
||||
product1.setImageUrlId(R.drawable.chengzi);
|
||||
product1.setProductName("橙子");
|
||||
product1.setProductPrice(new BigDecimal("29.9"));
|
||||
Product product2 = new Product();
|
||||
product2.setImageUrlId(R.drawable.youzi);
|
||||
product2.setProductName("柚子");
|
||||
product2.setProductPrice(new BigDecimal("19.9"));
|
||||
Product product3 = new Product();
|
||||
product3.setImageUrlId(R.drawable.xigua);
|
||||
product3.setProductName("西瓜");
|
||||
product3.setProductPrice(new BigDecimal("39.9"));
|
||||
Product product4 = new Product();
|
||||
product4.setImageUrlId(R.drawable.fuzhuang);
|
||||
product4.setProductName("衬衫");
|
||||
product4.setProductPrice(new BigDecimal("30.9"));
|
||||
Product product5 = new Product();
|
||||
product5.setImageUrlId(R.drawable.shenghuo);
|
||||
product5.setProductName("常用品");
|
||||
product5.setProductPrice(new BigDecimal("50"));
|
||||
Product product6 = new Product();
|
||||
product6.setImageUrlId(R.drawable.wenju);
|
||||
product6.setProductName("文具礼盒");
|
||||
product6.setProductPrice(new BigDecimal("49.9"));
|
||||
Product product7 = new Product();
|
||||
product7.setImageUrlId(R.drawable.shengxian);
|
||||
product7.setProductName("果蔬拼盘");
|
||||
product7.setProductPrice(new BigDecimal("25.7"));
|
||||
Product product8 = new Product();
|
||||
product8.setImageUrlId(R.drawable.shengxian);
|
||||
product8.setProductName("常用医药");
|
||||
product8.setProductPrice(new BigDecimal("19.9"));
|
||||
productList.add(product);
|
||||
productList.add(product1);
|
||||
productList.add(product2);
|
||||
productList.add(product3);
|
||||
productList.add(product4);
|
||||
productList.add(product5);
|
||||
productList.add(product6);
|
||||
productList.add(product7);
|
||||
productList.add(product8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化组件
|
||||
*/
|
||||
private void init() {
|
||||
titleList = findViewById(R.id.category_title_list);
|
||||
adapter = new Adapter(productCategory, CategoryActivity.this);
|
||||
titleList.setAdapter(adapter);
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.example.orangesale_05.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.example.orangesale_05.R;
|
||||
import com.example.orangesale_05.adapter.Adapter;
|
||||
import com.example.orangesale_05.entity.Product;
|
||||
import com.example.orangesale_05.fragment.SetDetailFragment;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CategoryActivity extends Activity {
|
||||
public OnChangeListener onchangedListener;
|
||||
private List<Product> productList;
|
||||
private List<String> productCategory = new ArrayList<>();
|
||||
private ListView titleList;
|
||||
private Adapter adapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.content_category);
|
||||
initData();
|
||||
init();
|
||||
SetDetailFragment fragment = new SetDetailFragment();
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
transaction.replace(R.id.category_detail, fragment);
|
||||
transaction.commit();
|
||||
titleList.setOnItemClickListener((parent, view, position, id) -> {
|
||||
adapter.setSelectedPosition(position);
|
||||
adapter.notifyDataSetInvalidated();
|
||||
if (onchangedListener != null) {
|
||||
onchangedListener.changeText(productList.get(position));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setOnChangeListener(OnChangeListener onChangeListener) {
|
||||
this.onchangedListener = onChangeListener;
|
||||
}
|
||||
|
||||
public interface OnChangeListener {
|
||||
void changeText(Product product);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
private void initData() {
|
||||
productList = new ArrayList<>();
|
||||
productCategory.add("橘子");
|
||||
productCategory.add("橙子");
|
||||
productCategory.add("柚子");
|
||||
Product product = new Product();
|
||||
product.setImageUrlId(R.drawable.arrow_down);
|
||||
product.setProductName("橘子");
|
||||
product.setProductPrice(new BigDecimal("9.9"));
|
||||
Product product1 = new Product();
|
||||
product1.setImageUrlId(R.drawable.orange);
|
||||
product1.setProductName("橙子");
|
||||
product1.setProductPrice(new BigDecimal("29.9"));
|
||||
Product product2 = new Product();
|
||||
product2.setImageUrlId(R.drawable.arrow_left);
|
||||
product2.setProductName("柚子");
|
||||
product2.setProductPrice(new BigDecimal("19.9"));
|
||||
productList.add(product);
|
||||
productList.add(product1);
|
||||
productList.add(product2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化组件
|
||||
*/
|
||||
private void init() {
|
||||
titleList = findViewById(R.id.category_title_list);
|
||||
adapter = new Adapter(productCategory, CategoryActivity.this);
|
||||
titleList.setAdapter(adapter);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_04.dataoperation;
|
||||
package com.example.orangesale_05.dataoperation;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_04.entity;
|
||||
package com.example.orangesale_05.entity;
|
||||
|
||||
public class OrangeUser {
|
||||
private Integer id;
|
@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#EFB81C" />
|
||||
<corners android:radius="5dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 377 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 193 KiB |
Before Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 586 KiB |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="#F0A732" android:state_selected="true" />
|
||||
<item android:color="#CFCFCF" />
|
||||
</selector>
|
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 54 KiB |
@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">橙一色</string>
|
||||
<string name="Username">用户名:</string>
|
||||
<string name="Password">密 码:</string>
|
||||
<string name="Password">密    码:</string>
|
||||
</resources>
|
@ -1,4 +1,4 @@
|
||||
package com.example.orangesale_04;
|
||||
package com.example.orangesale_05;
|
||||
|
||||
import org.junit.Test;
|
||||
|