直播带货源码,Android Studio购买售卖系统
直播带货源码,Android Studio购买售卖系统实现的相关代码
ShopActivity
package com.example.tryfirst;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class ShopActivity extends AppCompatActivity implements View.OnClickListener{
private ItemInfo itemInfo0;
private ItemInfo itemInfo1;
private ItemInfo itemInfo2;
private ItemInfo itemInfo3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shop);
itemInfo0 = new ItemInfo("空军一号");
itemInfo1 = new ItemInfo("李宁足球鞋");
itemInfo2 = new ItemInfo("匹克太极篮球鞋");
itemInfo3 = new ItemInfo("林丹羽毛球鞋");
findViewById(R.id.btn_0).setOnClickListener(this);
findViewById(R.id.btn_1).setOnClickListener(this);
findViewById(R.id.btn_2).setOnClickListener(this);
findViewById(R.id.btn_3).setOnClickListener(this);
}
public void onClick(View v){
Intent intent;
switch (v.getId()) {
case R.id.btn_0:
intent = new Intent();
intent.putExtra("shoe",itemInfo0);
setResult(1,intent);
finish();
break;
case R.id.btn_1:
intent = new Intent();
intent.putExtra("shoe",itemInfo1);
setResult(1,intent);
finish();
break;
case R.id.btn_2:
intent = new Intent();
intent.putExtra("shoe",itemInfo0);
setResult(1,intent);
finish();
break;
case R.id.btn_3:
intent = new Intent();
intent.putExtra("shoe",itemInfo0);
setResult(1,intent);
finish();
break;
}
}
}
ShowActivity
package com.example.tryfirst;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class ShowActivity extends AppCompatActivity {
private TextView tv_name;
private TextView tv_password;
private TextView shoe;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show);
Intent intent = getIntent();
String name = intent.getStringExtra("name");
String password = intent.getStringExtra("password");
tv_name = (TextView) findViewById(R.id.tv_name);
tv_password = (TextView) findViewById(R.id.tv_password);
tv_name.setText("用户名为: " + name);
tv_password.setText("密码为: " + password);
shoe = (TextView) findViewById(R.id.tv_food_progress);
}
public void click0(View view){
Intent intent = new Intent(this, FriendActivity.class);
startActivity(intent);
}
public void click1(View view){
Intent intent = new Intent(this,ShopActivity.class);
startActivityForResult(intent,1);
}
public void click2(View view){
Intent intent = new Intent(this,ListActivity.class);
startActivity(intent);
}
@Override
protected void onActivityResult(int requestCode,
int resultCode,Intent data){
super.onActivityResult(requestCode,resultCode,data);
if(data !=null){
if(requestCode==1){
if(resultCode==1){
ItemInfo info =
(ItemInfo) data.getSerializableExtra("food");
updateProgress(info);
}
}
}
}
private void updateProgress(ItemInfo info){shoe.setText(info.getName());
}
}
ListActivity
package com.example.tryfirst;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
public class ListActivity extends AppCompatActivity {
private ListView mListView;
private String[] names = {"郭艾伦aj34"};
private int[] herd = {R.drawable.l};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
mListView = (ListView) findViewById(R.id.lv);
MyBaseAdapter myAdapter = new MyBaseAdapter();
mListView.setAdapter(myAdapter);
}
class MyBaseAdapter extends BaseAdapter {
@Override
public int getCount() {
return names.length;
}
@Override
public Object getItem(int position) {
return names[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//将list.xml文件找出来转化为View对象
View view = View.inflate(ListActivity.this,R.layout.list,null);
TextView mTextView = (TextView) view.findViewById(R.id.tv);
mTextView.setText(names[position]);
ImageView imageView = (ImageView) view.findViewById(R.id.imge);
imageView.setBackgroundResource(herd[position]);
return view;
}
}
}
以上就是直播带货源码,Android Studio购买售卖系统实现的相关代码, 更多内容欢迎关注之后的文章