From 282a28978aee89e763cb87702e1d8eb037ef0684 Mon Sep 17 00:00:00 2001 From: Administrator <1512995449@qq.com> Date: Fri, 3 Jan 2020 08:59:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E8=82=96=E5=BF=97?= =?UTF-8?q?=E6=95=8F=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sj/raise_money/BrowseRecordActivity.java | 8 +-- .../sj/raise_money/DataBase/UserService.java | 2 +- .../java/hunnu/sj/raise_money/InfoUtils.java | 2 +- .../hunnu/sj/raise_money/MainActivity.java | 15 +++-- ...dAdapter.java => DonateRecordAdapter.java} | 5 +- .../donated_record/DonatedRecordAdapter.java | 52 +++++++++++++++ .../{donate_record => record}/Record.java | 2 +- .../main/res/layout/fragment_news_content.xml | 64 +++++++++++++++++-- .../main/res/layout/fragment_news_title.xml | 4 +- 9 files changed, 131 insertions(+), 23 deletions(-) rename app/src/main/java/hunnu/sj/raise_money/donate_record/{RecordAdapter.java => DonateRecordAdapter.java} (87%) create mode 100644 app/src/main/java/hunnu/sj/raise_money/donated_record/DonatedRecordAdapter.java rename app/src/main/java/hunnu/sj/raise_money/{donate_record => record}/Record.java (95%) diff --git a/app/src/main/java/hunnu/sj/raise_money/BrowseRecordActivity.java b/app/src/main/java/hunnu/sj/raise_money/BrowseRecordActivity.java index 0672c6a..ca6d7cb 100644 --- a/app/src/main/java/hunnu/sj/raise_money/BrowseRecordActivity.java +++ b/app/src/main/java/hunnu/sj/raise_money/BrowseRecordActivity.java @@ -11,13 +11,13 @@ import android.widget.ListView; import java.util.ArrayList; -import hunnu.sj.raise_money.donate_record.Record; -import hunnu.sj.raise_money.donate_record.RecordAdapter; +import hunnu.sj.raise_money.record.Record; +import hunnu.sj.raise_money.donate_record.DonateRecordAdapter; public class BrowseRecordActivity extends AppCompatActivity { private ArrayList records = new ArrayList<>(); private ListView lv_record; - private RecordAdapter recordAdapter; + private DonateRecordAdapter recordAdapter; private String username; private Handler mhandler = new Handler(){ @Override @@ -34,7 +34,7 @@ public class BrowseRecordActivity extends AppCompatActivity { setContentView(R.layout.activity_browse_record); Intent intent = getIntent(); username = intent.getStringExtra("username"); - recordAdapter = new RecordAdapter(this,records); + recordAdapter = new DonateRecordAdapter(this,records); lv_record = findViewById(R.id.lv_browse_denate_record); lv_record.setAdapter(recordAdapter); new BrowseRecordThread().start(); diff --git a/app/src/main/java/hunnu/sj/raise_money/DataBase/UserService.java b/app/src/main/java/hunnu/sj/raise_money/DataBase/UserService.java index 8b2c3bf..ae16143 100644 --- a/app/src/main/java/hunnu/sj/raise_money/DataBase/UserService.java +++ b/app/src/main/java/hunnu/sj/raise_money/DataBase/UserService.java @@ -10,7 +10,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; -import hunnu.sj.raise_money.donate_record.Record; +import hunnu.sj.raise_money.record.Record; import hunnu.sj.raise_money.news.News; import hunnu.sj.raise_money.R; import hunnu.sj.raise_money.User; diff --git a/app/src/main/java/hunnu/sj/raise_money/InfoUtils.java b/app/src/main/java/hunnu/sj/raise_money/InfoUtils.java index bdb8d1b..a54b577 100644 --- a/app/src/main/java/hunnu/sj/raise_money/InfoUtils.java +++ b/app/src/main/java/hunnu/sj/raise_money/InfoUtils.java @@ -5,7 +5,7 @@ import android.content.Context; import java.util.ArrayList; import hunnu.sj.raise_money.DataBase.UserService; -import hunnu.sj.raise_money.donate_record.Record; +import hunnu.sj.raise_money.record.Record; import hunnu.sj.raise_money.news.News; public class InfoUtils { diff --git a/app/src/main/java/hunnu/sj/raise_money/MainActivity.java b/app/src/main/java/hunnu/sj/raise_money/MainActivity.java index 2d9149e..d0c079f 100644 --- a/app/src/main/java/hunnu/sj/raise_money/MainActivity.java +++ b/app/src/main/java/hunnu/sj/raise_money/MainActivity.java @@ -110,10 +110,10 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte //new UploadThread().start(); lv_news = findViewById(R.id.list); lv_news.setAdapter(newsAdapter); - //lv_news.setOnItemClickListener(this); + lv_news.setOnItemClickListener(this); News news = new News(); - news.setTitle("火箭发射成功"); - news.setDes("地方上的房贷首付读书首付第三方的手房贷首付第三方的手负担"); + //news.setTitle("火箭发射成功"); + // news.setDes("地方上的房贷首付读书首付第三方的手房贷首付第三方的手负担"); news.setHead_icon(ContextCompat.getDrawable(this, R.drawable.ic_launcher_background)); list.add(news); new UploadThread().start(); @@ -134,10 +134,11 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte @Override//点击条目时调用该方法,parent指listview,position指条目位置 public void onItemClick(AdapterView parent, View view, int position, long id) { News news = (News)parent.getItemAtPosition(position); - String url = "www.baidu.com"; - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_VIEW); - intent.setData(Uri.parse(url)); + String title=news.getTitle(); + String des=news.getDes(); + Intent intent = new Intent(this,NewsContentActivity.class); + intent.putExtra("news_title",title); + intent.putExtra("news_des",des); startActivity(intent); } diff --git a/app/src/main/java/hunnu/sj/raise_money/donate_record/RecordAdapter.java b/app/src/main/java/hunnu/sj/raise_money/donate_record/DonateRecordAdapter.java similarity index 87% rename from app/src/main/java/hunnu/sj/raise_money/donate_record/RecordAdapter.java rename to app/src/main/java/hunnu/sj/raise_money/donate_record/DonateRecordAdapter.java index 13d4a70..a91f13c 100644 --- a/app/src/main/java/hunnu/sj/raise_money/donate_record/RecordAdapter.java +++ b/app/src/main/java/hunnu/sj/raise_money/donate_record/DonateRecordAdapter.java @@ -9,11 +9,12 @@ import android.widget.TextView; import java.util.ArrayList; import hunnu.sj.raise_money.R; +import hunnu.sj.raise_money.record.Record; -public class RecordAdapter extends BaseAdapter { +public class DonateRecordAdapter extends BaseAdapter { private ArrayList recordlist; private Context context; - public RecordAdapter(Context context,ArrayList recordlist) { + public DonateRecordAdapter(Context context, ArrayList recordlist) { this.context = context; this.recordlist = recordlist; diff --git a/app/src/main/java/hunnu/sj/raise_money/donated_record/DonatedRecordAdapter.java b/app/src/main/java/hunnu/sj/raise_money/donated_record/DonatedRecordAdapter.java new file mode 100644 index 0000000..dfa19a3 --- /dev/null +++ b/app/src/main/java/hunnu/sj/raise_money/donated_record/DonatedRecordAdapter.java @@ -0,0 +1,52 @@ +package hunnu.sj.raise_money.donated_record; + + import android.content.Context; + import android.view.View; + import android.view.ViewGroup; + import android.widget.BaseAdapter; + import android.widget.TextView; + + import java.util.ArrayList; + + import hunnu.sj.raise_money.R; + import hunnu.sj.raise_money.record.Record; + +public class DonatedRecordAdapter extends BaseAdapter { + private ArrayList recordlist; + private Context context; + public DonatedRecordAdapter(Context context, ArrayList recordlist) { + + this.context = context; + this.recordlist = recordlist; + } + @Override + public int getCount() { + return recordlist.size(); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public Object getItem(int position) { + return recordlist.get(position); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + View view = null; + if(convertView != null){ + view = convertView; + }else{ + view = View.inflate(context, R.layout.donate_record_item,null); + } + Record record = recordlist.get(position); + TextView record_vw = view.findViewById(R.id.record_descri); + String descri = "用户"+record.getUsername()+"于"+record.getTime()+"捐赠了"+record.getDonatemon()+"元"; + record_vw.setText(descri); + return view; + } +} + diff --git a/app/src/main/java/hunnu/sj/raise_money/donate_record/Record.java b/app/src/main/java/hunnu/sj/raise_money/record/Record.java similarity index 95% rename from app/src/main/java/hunnu/sj/raise_money/donate_record/Record.java rename to app/src/main/java/hunnu/sj/raise_money/record/Record.java index 3b475c1..0d30a88 100644 --- a/app/src/main/java/hunnu/sj/raise_money/donate_record/Record.java +++ b/app/src/main/java/hunnu/sj/raise_money/record/Record.java @@ -1,4 +1,4 @@ -package hunnu.sj.raise_money.donate_record; +package hunnu.sj.raise_money.record; public class Record { private long id = 0; diff --git a/app/src/main/res/layout/fragment_news_content.xml b/app/src/main/res/layout/fragment_news_content.xml index 14904ba..9efe1a5 100644 --- a/app/src/main/res/layout/fragment_news_content.xml +++ b/app/src/main/res/layout/fragment_news_content.xml @@ -1,26 +1,80 @@ + android:layout_height="match_parent"> + + android:visibility="invisible"> + + + + + + + + + + + + + +