@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
@ -1,62 +1,121 @@
|
||||
package com.orangesale.cn.activity;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import com.orangesale.cn.R;
|
||||
import android.view.View;
|
||||
import com.orangesale.cn.fragment.IndexFragment;
|
||||
import com.orangesale.cn.fragment.PersonFragment;
|
||||
import com.orangesale.cn.fragment.ProductFragment;
|
||||
import com.orangesale.cn.fragment.ShoppingFragment;
|
||||
|
||||
public class IndexActivity extends Activity implements ViewTreeObserver.OnDrawListener {
|
||||
private IndexFragment indexFragment;
|
||||
private ProductFragment productFragment;
|
||||
private ShoppingFragment shoppingFragment;
|
||||
private PersonFragment personFragment;
|
||||
|
||||
public class IndexActivity extends Activity implements View.OnClickListener {
|
||||
private LinearLayout indexLine;
|
||||
//private ProductFragment productFragment;
|
||||
private LinearLayout indexLine, productLine, shoppingLine, personLine;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_index);
|
||||
setContentView(R.layout.activity_main);
|
||||
init();
|
||||
initIndexFragment();
|
||||
}
|
||||
//组件初始化
|
||||
private void init(){
|
||||
|
||||
private void init() {
|
||||
indexLine = findViewById(R.id.content_index);
|
||||
indexLine.setOnClickListener(this);
|
||||
|
||||
indexLine = findViewById(R.id.content_product);
|
||||
productLine.setOnClickListener(this);
|
||||
|
||||
indexLine = findViewById(R.id.content_cart);
|
||||
shoppingLine.setOnClickListener(this);
|
||||
|
||||
indexLine = findViewById(R.id.content_person);
|
||||
productLine.setOnClickListener(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
switch (v.getId()){
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
|
||||
case R.id.content_index:
|
||||
initIndexFragment();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
case R.id.content_product:
|
||||
initproductFragment();
|
||||
break;
|
||||
|
||||
//初始化首页Fragment
|
||||
private void initIndexFragment(){
|
||||
/*
|
||||
FragmentTransaction transaction=getFragmentManager().beginTransaction();
|
||||
if(indexFragment==null){
|
||||
case R.id.content_cart:
|
||||
initshoppingFragment();
|
||||
break;
|
||||
|
||||
case R.id.content_person:
|
||||
//注册验证方法
|
||||
initpersonFragment();
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
//初始化产品fragment
|
||||
private void initproductFragment(){
|
||||
private void initIndexFragment() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
if (indexFragment == null) {
|
||||
indexFragment = new IndexFragment();
|
||||
transaction.replace(R.id.main_content, indexFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
}
|
||||
private void initproductFragment() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
if (productFragment == null) {
|
||||
productFragment = new ProductFragment();
|
||||
}
|
||||
transaction.replace(R.id.main_content, productFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
private void initshoppingCartFragment() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
if (shoppingFragment == null) {
|
||||
shoppingFragment = new ShoppingFragment();
|
||||
}
|
||||
transaction.replace(R.id.main_content, shoppingFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
private void initpersonFragment() {
|
||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||
|
||||
if (personFragment == null) {
|
||||
Intent intent = IndexActivity.this.getIntent();
|
||||
Bundle bundle = intent.getExtras();
|
||||
personFragment = new PersonFragment();
|
||||
personFragment.setArguments(bundle);
|
||||
}
|
||||
transaction.replace(R.id.main_content, personFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//初始化购物车fragment
|
||||
private void initshoppingCarFragment(){
|
||||
@Override
|
||||
public void onDraw() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//初始化个人fragment
|
||||
private void initpersonFragment(){
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.orangesale.cn.fragment;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.GridView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SearchView;
|
||||
import com.orangesale.cn.R;
|
||||
import com.orangesale.cn.adapter.Adapter;
|
||||
import com.orangesale.cn.entity.Product;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class IndexFragment extends Fragment implements View.OnClickListener {
|
||||
private SearchView searchView;
|
||||
private LinearLayout bingtangchengLine;
|
||||
private GridView gridView;
|
||||
private Adapter adapter;
|
||||
private List<Product> productList;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
||||
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_index,container,false);
|
||||
init(view);
|
||||
return view;
|
||||
}
|
||||
private void init(View view){
|
||||
searchView = view.findViewById(R.id.searchView);
|
||||
searchView.setOnClickListener(this);
|
||||
initData();
|
||||
adapter = new Adapter(getActivity(),productList);
|
||||
gridView.setAdapter(adapter);
|
||||
}
|
||||
@Override
|
||||
public void initData(){
|
||||
productList = new ArrayList<>();
|
||||
Product product = new Product();
|
||||
product.setImageUrlId(R.drawable.bingtangcheng);
|
||||
product.setProductName("冰糖橙");
|
||||
product.setProductPrice(new BigDecimal("9.9"));
|
||||
|
||||
Product product1 = new Product();
|
||||
product1.setImageUrlId(R.drawable.chucheng);
|
||||
product1.setProductName("褚橙");
|
||||
product1.setProductPrice(new BigDecimal("29.9"));
|
||||
|
||||
productList.add(product);
|
||||
productList.add(product1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.orangesale.cn.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.orangesale.cn.R;
|
||||
|
||||
import android.app.Fragment;
|
||||
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
|
||||
public class PersonFragment extends Fragment implements View.OnClickListener {
|
||||
private ImageView userIconImage;
|
||||
private TextView usernameText, userSexText, userCityText;
|
||||
private LinearLayout usernameLine, userSexline, userCityLine, userPayLine, userSettingLine, userGeneralLine;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_user, container, false);
|
||||
init(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件初始化
|
||||
*/
|
||||
private void init(View view) {
|
||||
userIconImage = view.findViewById(R.id.user_icon);
|
||||
usernameText = view.findViewById(R.id.user_username);
|
||||
userSexText = view.findViewById(R.id.user_sex);
|
||||
userCityText = view.findViewById(R.id.user_city);
|
||||
usernameLine = view.findViewById(R.id.user_username_line);
|
||||
userSexline = view.findViewById(R.id.user_sex_line);
|
||||
userCityLine = view.findViewById(R.id.user_city_line);
|
||||
userPayLine = view.findViewById(R.id.user_pay);
|
||||
userSettingLine = view.findViewById(R.id.user_setting);
|
||||
userGeneralLine = view.findViewById(R.id.user_general);
|
||||
setData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件赋值
|
||||
*/
|
||||
private void setData() {
|
||||
Bundle bundle = getArguments();
|
||||
usernameText.setText(String.format("用户名:%s", bundle.getString("username")));
|
||||
userSexText.setText(String.format("性别:%s", bundle.getString("sex")));
|
||||
userCityText.setText(String.format("城市:%s", bundle.getString("city")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.orangesale.cn.fragment;
|
||||
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.orangesale.cn.R;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
|
||||
public class ProductFragment extends Fragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_product, container, false);
|
||||
return view;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.orangesale.cn.fragment;
|
||||
|
||||
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.orangesale.cn.R;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
|
||||
public class ShoppingFragment extends Fragment {
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = LayoutInflater.from(getActivity()).inflate(R.layout.content_shopping, container, false);
|
||||
return view;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<!-- 连框颜色值 -->
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#dddddd" />
|
||||
</shape>
|
||||
</item>
|
||||
<!-- 主体背景颜色值 -->
|
||||
<item android:bottom="1dp"> <!--设置只有底部有边框-->
|
||||
<shape>
|
||||
<solid android:color="#ffffff" />
|
||||
<corners android:radius="10dp"></corners>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 6.0 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: 17 KiB After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 9.3 KiB |
@ -1,18 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/activity_main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
android:orientation="vertical"
|
||||
tools:context=".activity.IndexActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="5">
|
||||
<include layout = "@layout/content_user"/>
|
||||
</LinearLayout>-->
|
||||
<FrameLayout
|
||||
android:id="@+id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp">
|
||||
<!--底部导航-->
|
||||
<include layout = "@layout/content_nav"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,20 @@
|
||||
<?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:orientation="vertical"
|
||||
android:background="#E8E8E8">
|
||||
|
||||
|
||||
<SearchView
|
||||
android:id="@+id/searchView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/index_menu"
|
||||
android:focusable="false"
|
||||
android:iconifiedByDefault="false"
|
||||
android:queryHint="请输入搜索内容"/>
|
||||
|
||||
|
||||
/>
|
||||
</LinearLayout>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
tools:context=".fragment.PersonFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
tools:context=".fragment.ProductFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
tools:context=".fragment.ShoppingFragment">
|
||||
|
||||
<!-- TODO: Update blank fragment layout -->
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|