@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="emulator-5554" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-04-01T11:11:38.454193600Z" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,34 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CustomAdapter extends ArrayAdapter<Item> {
|
||||
public CustomAdapter(Context context, ArrayList<Item> items) {
|
||||
super(context, 0, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Item item = getItem(position);
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(getContext())
|
||||
.inflate(R.layout.list_item, parent, false);
|
||||
}
|
||||
TextView price = (TextView) convertView.findViewById(R.id.price);
|
||||
price.setText(item.getPrice());
|
||||
System.out.println(price);
|
||||
TextView name = (TextView) convertView.findViewById(R.id.name);
|
||||
name.setText(item.getText());
|
||||
ImageView imageView = (ImageView) convertView.findViewById(R.id.image);
|
||||
imageView.setImageResource(item.getImageResourceId());
|
||||
return convertView;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GoodsActivity extends AppCompatActivity {
|
||||
private static final String[] mListData = {"太阳", "水星", "金星", "地球", "火星", "木星", "土星", "天王星", "海王星", "谷神星", "冥王星", "鸟神星", "妊神星", "阋神星"};
|
||||
private static final String[] strs = new String[]{
|
||||
"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "二十一", "二十二", "二十三"};
|
||||
|
||||
private ListView shoesList;
|
||||
private Button shoesButton, clothesButton;
|
||||
List mAddHeaderFooterList = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_goods);
|
||||
init();
|
||||
shoesButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ArrayList<Item> items = new ArrayList<>();
|
||||
items.add(new Item("599元", "欧文五", R.drawable.kyrie5));
|
||||
items.add(new Item("699元", "欧文infinity", R.drawable.kyrieinfinity));
|
||||
items.add(new Item("899元", "欧文low 五", R.drawable.kyrielow5));
|
||||
|
||||
CustomAdapter adapter = new CustomAdapter(GoodsActivity.this, items);
|
||||
shoesList.setAdapter(adapter);
|
||||
// shoesList.setAdapter(new ArrayAdapter<String>(GoodsActivity.this, android.R.layout.simple_list_item_1, strs));
|
||||
}
|
||||
});
|
||||
|
||||
clothesButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
ArrayList<Item> items = new ArrayList<>();
|
||||
items.add(new Item("599", "篮网球衣白", R.drawable.clothewhite));
|
||||
items.add(new Item("699", "篮网球衣黑", R.drawable.clotheblack));
|
||||
|
||||
CustomAdapter adapter = new CustomAdapter(GoodsActivity.this, items);
|
||||
shoesList.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void init() {
|
||||
shoesButton = findViewById(R.id.shoes);
|
||||
shoesList = findViewById(R.id.shoesView);
|
||||
clothesButton = findViewById(R.id.clothes);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GoodsFragment extends Fragment {
|
||||
|
||||
private static final String[] strs = new String[]{
|
||||
"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "二十一", "二十二", "二十三"};
|
||||
|
||||
private ListView shoesList;
|
||||
private Button shoesButton;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_goods, null);
|
||||
return view;
|
||||
}
|
||||
|
||||
void init(View view) {
|
||||
shoesButton = view.findViewById(R.id.shoes);
|
||||
shoesList = view.findViewById(R.id.shoesView);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.example.myapplication;
|
||||
|
||||
public class Item {
|
||||
private String mText;
|
||||
|
||||
private String price;
|
||||
private int mImageResourceId;
|
||||
|
||||
public Item(String price, String text, int imageResourceId) {
|
||||
this.price = price;
|
||||
mText = text;
|
||||
mImageResourceId = imageResourceId;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return mText;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public int getImageResourceId() {
|
||||
return mImageResourceId;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 207 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 124 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 665 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 52 KiB |
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fragment1"
|
||||
android:name="com.example.myapplication.GoodsFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/nike"></ImageView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_left"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Button
|
||||
android:background="@color/white"
|
||||
android:id="@+id/shoes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="球 鞋 >"
|
||||
android:textSize="20dp"
|
||||
android:textColor="@color/black"></Button>
|
||||
|
||||
<Button
|
||||
android:background="@color/white"
|
||||
android:id="@+id/clothes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="球 衣>"
|
||||
android:textSize="20dp"
|
||||
android:textColor="@color/black"></Button>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/fl_right"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:background="@color/nike">
|
||||
|
||||
|
||||
<ListView
|
||||
android:id="@+id/shoesView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:entries="@array/goods"></ListView>
|
||||
</FrameLayout>
|
||||
|
||||
<!-- <ListView-->
|
||||
<!-- android:id="@+id/lv"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content" />-->
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
app:cardCornerRadius="8dp"
|
||||
app:cardElevation="8dp"
|
||||
app:cardUseCompatPadding="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="100dp"
|
||||
android:scaleType="centerInside"
|
||||
app:srcCompat="@drawable/flowerr" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="59dp"
|
||||
android:text="Product Name"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/price"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:text="Price: $9.99"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:padding="8dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="50dp"
|
||||
android:scaleType="centerInside"
|
||||
app:srcCompat="@drawable/flowerr" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Product Name"
|
||||
android:textSize="19sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/price"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="30dp"
|
||||
android:text="Price: $9.99"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|