通过前面一篇,“我的”页面的后台就搭建完整了,接下来就继续处理一下Android端下“我的”页面剩余还未完成的功能——修改密码、查看我的分享、查看我的日记、查看我的收藏、查看iShare相关

1.修改密码的页面设计——activity_change_password.xml

  • 页面包括旧密码输入框、新密码输入框,具体代码如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#eeeeee"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="70dp"android:background="@color/color_minefragment_top"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:textAlignment="center"android:text="修改密码"android:textColor="#fff"android:textSize="20dp"android:layout_centerVertical="true"android:layout_marginLeft="20dp"/></RelativeLayout><LinearLayoutandroid:id="@+id/password_change_layout"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:layout_marginTop="120dp"android:layout_marginLeft="50dp"android:layout_marginRight="50dp"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="旧 密 码:"android:textSize="@dimen/textSize_normal"/><EditTextandroid:id="@+id/et_old_login_password"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="@dimen/textSize_normal"android:inputType="textPassword"android:hint="这里填写旧密码"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_marginTop="12dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="@dimen/textSize_normal"android:text="新 密 码:"/><EditTextandroid:id="@+id/et_new_login_password"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="@dimen/textSize_normal"android:inputType="textPassword"android:hint="这里填写新密码"/></LinearLayout></LinearLayout><Buttonandroid:id="@+id/bt_change_password"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/password_change_layout"android:layout_marginTop="20dp"android:layout_marginLeft="150dp"android:layout_marginRight="150dp"android:background="@drawable/selector_loginactivity_button"android:text="修改"android:textColor="#fff"android:gravity="center"android:onClick="onClick"/><TextViewandroid:id="@+id/bt_changePassword_view_info"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:layout_marginVertical="30dp"android:text="信息反馈"android:textColor="#B3B3B3"android:gravity="center"/>
</RelativeLayout>

2.修改密码页面的逻辑

  • 在之前创建好的com.example.discover包中创建class命名为ChangePassword.java
  • 在AndroidManifest.xml中添加配置:
<activity android:name=".ChangePassword"android:label="更改密码">
</activity>
  • ChangePassword.java文件处理的逻辑就是获取到用户的昵称、用户输入的旧密码、用户输入的新密码,然后请求已经创建好的servlet——ChangePassword,然后得到是否修改成功的返回信息,ChangePassword.java文件具体代码如下
package com.example.discover;import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;public class ChangePassword extends Activity {EditText old_pass_et;   //旧密码EditText new_pass_et;   //新密码Button sure_change_pass;   //确定修改String baseUrl = "http://10.0.2.2:8080/iShareService/servlet/";   //web服务器的地址String imgBaseUrl = "http://10.0.2.2:8080/iShareService/images/";  //图片资源String userName,oldPass,newPass;   //存放用户基本信息@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_change_password);old_pass_et = (EditText) findViewById(R.id.et_old_login_password); //新密码new_pass_et = (EditText) findViewById(R.id.et_new_login_password); //新密码sure_change_pass = (Button)findViewById(R.id.bt_change_password) ;//确定修改密码的按钮setBaseInfo();sure_change_pass.setOnClickListener(new ChangePassword.onClick());}class onClick implements View.OnClickListener {@Overridepublic void onClick(View v) {oldPass = old_pass_et.getText().toString();newPass = new_pass_et.getText().toString();StringBuilder stringBuilder = new StringBuilder();BufferedReader buffer = null;HttpURLConnection connGET = null;if(oldPass.length()==0||newPass.length()==0){Toast.makeText(ChangePassword.this, "密码不能为空", Toast.LENGTH_LONG).show();return;}try {String registerUrl = baseUrl+"ChangePassword?oldPass="+oldPass+"&newPass="+newPass+"&username="+userName;URL url = new URL(registerUrl);connGET = (HttpURLConnection) url.openConnection();connGET.setConnectTimeout(5000);connGET.setRequestMethod("GET");if (connGET.getResponseCode() == 200) {buffer = new BufferedReader(new InputStreamReader(connGET.getInputStream()));for (String s = buffer.readLine(); s != null; s = buffer.readLine()) {stringBuilder.append(s);}Toast.makeText(ChangePassword.this, stringBuilder.toString(), Toast.LENGTH_LONG).show();//通过handler设置延时1秒后执行r任务,跳转到我的页面new Handler().postDelayed(new ChangePassword.LoadMainTask(),500);buffer.close();}else{Toast.makeText(ChangePassword.this,"非200.."+connGET.getResponseCode() , Toast.LENGTH_LONG).show();}} catch (Exception e) {e.printStackTrace();Toast.makeText(ChangePassword.this, "get 提交 err.." + e.toString(), Toast.LENGTH_LONG).show();}}}//启动线程,加载我的页面private class LoadMainTask implements Runnable{@Overridepublic void run() {Intent intent = new Intent(ChangePassword.this,MyTabFragment.class);/*startActivity(intent);*/setResult(2, intent); //这里的2就对应到onActivityResult()方法中的resultCodefinish();}}//获取用户信息public void setBaseInfo(){//获取最新的登录状态,SharePreferences为永久存储,需要手动退出SharedPreferences sp = ChangePassword.this.getSharedPreferences("save", Context.MODE_PRIVATE);userName = sp.getString("name","");}
}

3.我的分享、我的日记、我的收藏 页面设计

  • 这三个功能按钮都是跳转到的页面其实是同一个,只不过内容获取是不一样的,所以在这里只需要写一个详情页就可以了
  • 在layout下新建activity_about_me.xml文件,在该布局下就只需要要一个ListView就可以了,详细代码如下:
<?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"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="15dp"android:paddingRight="15dp"android:orientation="vertical"android:paddingTop="20dp"android:paddingBottom="20dp"><ListViewandroid:id="@+id/my_share_listView"android:layout_width="fill_parent"android:layout_height="wrap_content"android:dividerHeight="15dp" /></LinearLayout>
</LinearLayout>

4.我的分享、我的日记、我的收藏 页面的逻辑

  • 在已经创建好的com.example.discover包中创建class——MyShareList.java
  • 因为是跳转页面,所以在AndroidMainifest.xml中要添加配置
<activity android:name=".MyShareList"android:label="关于我的">
</activity>
  • 该文件处理的主要部分就是,获取到上一个页面传递的type(用于判断请求的是我的分享、我的日记还是我的收藏),然后获取到该用户的昵称,通过这两个参数请求后台的servlet——QueryAboutMe.java,返回相对应类型的内容,MyShareList.java具体代码如下:
package com.example.discover;import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.StrictMode;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;import com.example.bean.FindInfo;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;public class MyShareList extends Activity implements AbsListView.OnScrollListener{Activity mActivity;     //存放当前的activityString baseUrl = "http://10.0.2.2:8080/iShareService/servlet/";   //web服务器的地址String imgBaseUrl = "http://10.0.2.2:8080/iShareService/images/";  //图片资源int requestType=0;   //请求类型,0:我的分享、1:我的日记;2:我的收藏String userName="";String requestUrl="";private TextView title;private MyShareList.PaginationAdapter adapterAction;private ScheduledExecutorService scheduledExecutorService;private ListView listView;private int page = 1; //请求页数private int count = 10; //每次请求的数量private int visibleLastIndex = 0;  //最后的可视项索引private int visibleItemCount;    // 当前窗口可见项总数private int dataSize = 28;     //数据集的条数private MyShareList.PaginationAdapter adapter;private View loadMoreView;private Button loadMoreButton;private Handler handler = new Handler();//返回测试信息/*TextView testTxt;*/public  void refreshDiscover(){page = 1;visibleLastIndex = 0;listView.setAdapter(null);   //将ListView控件的内容清空initializeAdapter();listView.setAdapter(adapter);adapter.notifyDataSetChanged();}/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_about_me);mActivity = MyShareList.this;//取得启动该Activity的Intent对象Intent intent =getIntent();//获取最新的登录状态,SharePreferences为永久存储,需要手动退出SharedPreferences sp = MyShareList.this.getSharedPreferences("save", Context.MODE_PRIVATE);userName = sp.getString("name","");requestType =intent.getIntExtra("requestType",0);//取出Intent中附加的数据if(requestType==0){requestUrl = baseUrl+"QueryAboutMe?username="+userName+"&type=0&page="+page+"&count="+count;}else if(requestType==1){requestUrl = baseUrl+"QueryAboutMe?username="+userName+"&type=1&page="+page+"&count="+count;}else{requestUrl = baseUrl+"QueryAboutMe?username="+userName+"&type=2&page="+page+"&count="+count;}loadMoreView = getLayoutInflater().inflate(R.layout.activity_find_loadmore, null);loadMoreButton = (Button)loadMoreView.findViewById(R.id.loadMoreButton);loadMoreButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {loadMoreButton.setText("正在加载中...");  //设置按钮文字handler.postDelayed(new Runnable() {@Overridepublic void run() {loadMoreData();adapter.notifyDataSetChanged();loadMoreButton.setText("查看更多..."); //恢复按钮文字}},2000);}});//返回测试信息/* testTxt = (TextView)getActivity().findViewById(R.id.test_discover_tab);*/listView = (ListView)findViewById(R.id.my_share_listView);listView.addFooterView(loadMoreView);  //设置列表底部视图initializeAdapter();listView.setAdapter(adapter);listView.setOnScrollListener(this);listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {TextView getTvId = (TextView)view.findViewById(R.id.cardId);/*Toast.makeText(mActivity,"点击了"+getTvId.getText().toString()+"id", Toast.LENGTH_SHORT).show();*/SharedPreferences sp = mActivity.getSharedPreferences("save", Context.MODE_PRIVATE);Boolean isLogin = sp.getBoolean("isLogin",false);if(isLogin){//点击了进入详情Intent display_info_intent = new Intent();display_info_intent.setClass(mActivity, DisplayDetail.class);  //创建intent对象,并制定跳转页面display_info_intent.putExtra("infoId",getTvId.getText().toString());mActivity.setResult(1, display_info_intent); //这里的1就对应到onActivityResult()方法中的resultCodestartActivity(display_info_intent);    //跳转到详情页面}else{//尚未登录Toast.makeText(MyShareList.this,"请先登录", Toast.LENGTH_LONG).show();}}});}@Overridepublic void onScrollStateChanged(AbsListView view, int scrollState) {int itemsLastIndex = adapter.getCount()-1; //数据集最后一项的索引int lastIndex = itemsLastIndex + 1;if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE&& visibleLastIndex == lastIndex) {// 如果是自动加载,可以在这里放置异步加载数据的代码}}@Overridepublic void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) {this.visibleItemCount = visibleItemCount;visibleLastIndex = firstVisibleItem + visibleItemCount - 1;  //最后的可视项索引//如果所有的记录选项等于数据集的条数,则移除列表底部视图if(totalItemCount == dataSize+1){listView.removeFooterView(loadMoreView);Toast.makeText(MyShareList.this,  "数据全部加载完!", Toast.LENGTH_LONG).show();}}/*** 查询数据库中的数据*/private JSONArray loadDataFromDataBase(String loadDataUrl){StringBuilder stringBuilder = new StringBuilder();BufferedReader buffer = null;HttpURLConnection connGET = null;try {URL url = new URL(loadDataUrl);connGET = (HttpURLConnection) url.openConnection();connGET.setConnectTimeout(5000);connGET.setRequestMethod("GET");if (connGET.getResponseCode() == 200) {buffer = new BufferedReader(new InputStreamReader(connGET.getInputStream()));for (String s = buffer.readLine(); s != null; s = buffer.readLine()) {stringBuilder.append(s);}if(stringBuilder.toString()!="null"){//返回测试信息JSONArray jsonArray = new JSONArray(stringBuilder.toString());//获取到的数据,对Json进行解析page = page+1;  //一次成功请求后更新请求页面buffer.close();return jsonArray;}else{return null;}}else{Toast.makeText(MyShareList.this,"非200", Toast.LENGTH_LONG).show();}} catch (Exception e) {e.printStackTrace();Toast.makeText(MyShareList.this, "get 提交 err.." + e.toString(), Toast.LENGTH_LONG).show();}return null;}//初始化将详情设置到FindInfo bean中public List<FindInfo> initSetDataToBean(String detail){List<FindInfo> findInfo = new ArrayList<FindInfo>();try {JSONArray detailJsonArray = new JSONArray(detail);for (int i = 0; i < detailJsonArray.length(); i++) {FindInfo items = new FindInfo();JSONObject temp = (JSONObject) detailJsonArray.get(i);Integer infoId = temp.getInt("infoId");    //内容IDString infoTitle = temp.getString("infoTitle");   //内容标题String infoDescribe = temp.getString("infoDescribe");   //内容简述String infoDetail = temp.getString("infoDetail");   //内容详情Integer type = temp.getInt("infoType");    //类型:0表示日记,1表示趣事Integer support = temp.getInt("infoSupport");   //点赞数String infoAuthor = temp.getString("infoAuthor");  //作者items.setInfoId(infoId);items.setInfoTitle(infoTitle);items.setInfoDescribe(infoDescribe);items.setInfoDetail(infoDetail);items.setType(type);items.setSupport(support);items.setInfoAuthor(infoAuthor);findInfo.add(items);}return findInfo;}catch (JSONException e){Toast.makeText(MyShareList.this, "initSetDataToBean异常 err.." + e.toString(), Toast.LENGTH_LONG).show();return null;}}//加载更多将详情设置到FindInfo bean中public void loadMoreSetDataToBean(String detail){try {JSONArray detailJsonArray = new JSONArray(detail);for (int i = 0; i < detailJsonArray.length(); i++) {FindInfo items = new FindInfo();JSONObject temp = (JSONObject) detailJsonArray.get(i);Integer infoId = temp.getInt("infoId");    //内容IDString infoTitle = temp.getString("infoTitle");   //内容标题String infoDescribe = temp.getString("infoDescribe");   //内容简述String infoDetail = temp.getString("infoDetail");   //内容详情Integer type = temp.getInt("infoType");    //类型:0表示日记,1表示趣事Integer support = temp.getInt("infoSupport");   //点赞数String infoAuthor = temp.getString("infoAuthor");  //作者items.setInfoId(infoId);items.setInfoTitle(infoTitle);items.setInfoDescribe(infoDescribe);items.setInfoDetail(infoDetail);items.setType(type);items.setSupport(support);items.setInfoAuthor(infoAuthor);adapter.addNewsItem(items);   //与初始化是有差异的}}catch (JSONException e){Toast.makeText(MyShareList.this, "loadMoreSetDataToBean异常 err.." + e.toString(), Toast.LENGTH_LONG).show();}}/*** 初始化ListView的适配器,即打开页面展示的数据*/private void initializeAdapter(){// 设置线程策略setVersion();JSONArray jsonArray = loadDataFromDataBase(requestUrl);if(jsonArray!=null){try {JSONObject totalObject = (JSONObject)jsonArray.get(0);dataSize = totalObject.getInt("totalRecord");  //总记录数String detail= totalObject.getString("RecordDetail");   //详情if(initSetDataToBean(detail)!=null) {adapter = new MyShareList.PaginationAdapter(initSetDataToBean(detail));   //将详情设置到bean中}}catch (JSONException e){Toast.makeText(MyShareList.this, "initializeAdapter异常 err.." + e.toString(), Toast.LENGTH_LONG).show();}}else{listView.removeFooterView(loadMoreView);Toast.makeText(MyShareList.this, "查询为空" , Toast.LENGTH_LONG).show();}}//APP如果在主线程中请求网络操作,将会抛出异常,所以需要用线程来操作网络请求void setVersion() {StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() //探测SQLite数据库操作.penaltyLog() //打印logcat.penaltyDeath().build());}/*** 加载更多数据*/private void loadMoreData(){JSONArray jsonArray = loadDataFromDataBase(requestUrl);try {JSONObject total = (JSONObject) jsonArray.get(0);dataSize = total.getInt("totalRecord");  //总记录数String detail= total.getString("RecordDetail");   //详情loadMoreSetDataToBean(detail);   //将更多的详情设置到bean中}catch (JSONException e){Toast.makeText(MyShareList.this, "loadMoreData()异常 err.." + e.toString(), Toast.LENGTH_LONG).show();}}/*** 将一组数据传到ListView等UI显示组件*/class PaginationAdapter extends BaseAdapter {List<FindInfo> newsItems;public PaginationAdapter(List<FindInfo> newsitems) {this.newsItems = newsitems;}@Overridepublic int getCount() {return newsItems.size();}@Overridepublic Object getItem(int position) {return newsItems.get(position);}@Overridepublic long getItemId(int position) {return position;}//在这里将Item设置到每个卡片@Overridepublic View getView(int position, View view, ViewGroup parent) {if (view == null) {view = getLayoutInflater().inflate(R.layout.activity_find_list_item, null);}//标题TextView tvTitle = (TextView) view.findViewById(R.id.cardTitle);tvTitle.setText(newsItems.get(position).getInfoTitle());//文章IDTextView tvId = (TextView) view.findViewById(R.id.cardId);tvId.setText(newsItems.get(position).getInfoId().toString());int type = newsItems.get(position).getType();if (type == 0 || type == 3) {ImageView cardImgTip = (ImageView) view.findViewById(R.id.cardImgTip);if (type == 0) {cardImgTip.setImageResource(R.drawable.share_funny_select);} else {cardImgTip.setImageResource(R.drawable.share_diary_select);}TextView tvContent = (TextView) view.findViewById(R.id.cardContent);tvContent.setVisibility(View.VISIBLE);  //显示文字框ImageView ivContent = (ImageView) view.findViewById(R.id.cardContent_pic);ivContent.setVisibility(View.GONE);   //设置图片显示框隐藏LinearLayout layoutMusic = (LinearLayout) view.findViewById(R.id.cardContent_music);layoutMusic.setVisibility(View.GONE);   //设置音乐显示框隐藏//分享的普通内容tvContent.setText(newsItems.get(position).getInfoDescribe());} else if (type == 1) {ImageView cardImgTip = (ImageView) view.findViewById(R.id.cardImgTip);cardImgTip.setImageResource(R.drawable.share_pic_select);//分享图片TextView tvContent = (TextView) view.findViewById(R.id.cardContent);tvContent.setVisibility(View.GONE);  //隐藏文字框LinearLayout layoutMusic = (LinearLayout) view.findViewById(R.id.cardContent_music);layoutMusic.setVisibility(View.GONE);   //设置音乐显示框隐藏ImageView ivContent = (ImageView) view.findViewById(R.id.cardContent_pic);//通过网络链接获取图片Bitmap one;String describeUrl = newsItems.get(position).getInfoDescribe().trim();try {one = LoadImgByNet.getBitmap(imgBaseUrl + describeUrl);  //设置图片ivContent.setImageBitmap(one);} catch (IOException e) {e.printStackTrace();}ivContent.setVisibility(View.VISIBLE);   //设置图片显示框} else if (type == 2) {ImageView cardImgTip = (ImageView) view.findViewById(R.id.cardImgTip);cardImgTip.setImageResource(R.drawable.share_music_select);//分享的音乐TextView tvContent = (TextView) view.findViewById(R.id.cardContent);tvContent.setVisibility(View.GONE);  //显示文字框ImageView ivContent = (ImageView) view.findViewById(R.id.cardContent_pic);ivContent.setVisibility(View.GONE);   //设置图片显示框隐藏LinearLayout layoutMusic = (LinearLayout) view.findViewById(R.id.cardContent_music);TextView tvMusicContent = (TextView) view.findViewById(R.id.cardTitle_music);tvMusicContent.setText(newsItems.get(position).getInfoDescribe());layoutMusic.setVisibility(View.VISIBLE);   //设置音乐显示框显示}return view;}/*** 添加数据列表项** @param infoItem*/public void addNewsItem(FindInfo infoItem) {newsItems.add(infoItem);}}}

5.iShare相关页面设计

  • 在layout下新建文件activity_about_ishare.xml,具体代码如下
  • 这个页面设计比较简单,主要就是介绍iShare应用的开发目的和实现功能,没有功能,只是展示信息
<?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"><ScrollViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:fadingEdge="none" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:paddingLeft="14dp"android:paddingRight="14dp"android:paddingBottom="60dp"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="22dp"android:textStyle="bold"android:text="关于iShare" /><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="10dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:textSize="18sp"android:layout_weight="1"android:textColor="#000000"android:text="开发者学号:\n201611671208\n201611671206\n201611671221\n" /></LinearLayout><TextViewandroid:background="@drawable/list_card_style"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="@dimen/margin_10"android:padding="10dp"android:textSize="18sp"android:textColor="#000000"android:text="iShare应用:发现有趣的人和事,在这个平台可以发布自己感兴趣的内容以及查看大家的分享,简历良好的交流氛围"/><TextViewandroid:id="@+id/detail_info_detail"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="@dimen/margin_10"android:padding="10dp"android:textSize="18sp"android:textColor="#000000"android:singleLine="false"android:text="  开发目的:Android课程设计\n\n开发时间:2019年5月\n\n素材来源:LOGO是网络资源图,Icon来自www.iconfont.cn,其中用于测试的图片均来自网络\n\n项目代码:部分结构参考自CSDN、GitHub\n\n实现功能:起始页、注册、登录、更新签名、更改密码、浏览分享、按标题和简述关键字查找分享的内容、根据用户昵称查找用户、查看分享详情、点赞、收藏、发布四种类型的内容、查看按点赞数排行前十的内容、删除发布的内容、评论、查看我的分享、查看我的日记、查看我的收藏" /></LinearLayout></ScrollView>
</LinearLayout>

6.“我的”页面跳转事件

  • 打开之前创建好的MyTabFragment.java文件,给对应的五个Button——“修改密码”、“查看我的分享”、“查看我的日记”、“查看我的收藏”、“查看iShare相关”添加点击监听
//“我的”页面中相关点击事件class mClick implements View.OnClickListener {public void onClick(View v) {if(isLogin) {if (v == account_set_bt) {//点击了账号管理Intent account_manage_intent = new Intent();account_manage_intent.setClass(mActivity, AccountManagement.class);  //创建intent对象,并制定跳转页面startActivity(account_manage_intent);    //跳转到账号管理页面/*TextView textView = (TextView) getActivity().findViewById(R.id.test_text_view);  //用于放测试的提示信息Toast.makeText(getActivity(), textView.getText(), Toast.LENGTH_LONG).show();*/}else if(v == signature_set_bt){//点击了更改签名Intent signature_manage_intent = new Intent();signature_manage_intent.setClass(mActivity, ChangeSignature.class);  //创建intent对象,并指定跳转页面//startActivity(signature_manage_intent);    //跳转到更新签名页面startActivityForResult(signature_manage_intent,1);   //需要返回该页面}else if(v == password_set_bt){//点击了更改密码Intent password_manage_intent = new Intent();password_manage_intent.setClass(mActivity, ChangePassword.class);  //创建intent对象,并指定跳转页面/*startActivity(password_manage_intent);   */startActivityForResult(password_manage_intent,2);   // 跳转到修改密码页面}else if(v == share_list_bt){//点击了我的分享Intent intent = new Intent();intent.setClass(mActivity, MyShareList.class);  //创建intent对象,并指定跳转页面intent.putExtra("requestType",0);mActivity.setResult(4, intent); //这里的4就对应到onActivityResult()方法中的resultCodestartActivity(intent);    //跳转到list}else if(v==diary_list_bt){//点击了我的日记Intent intent = new Intent();intent.setClass(mActivity, MyShareList.class);  //创建intent对象,并指定跳转页面intent.putExtra("requestType",1);mActivity.setResult(5, intent); //这里的4就对应到onActivityResult()方法中的resultCodestartActivity(intent);    //跳转到list}else if(v==focus_list_bt){//点击了我的收藏Intent intent = new Intent();intent.setClass(mActivity, MyShareList.class);  //创建intent对象,并指定跳转页面intent.putExtra("requestType",2);mActivity.setResult(6, intent); //这里的4就对应到onActivityResult()方法中的resultCodestartActivity(intent);    //跳转到list} else if(v==about_iShare){//点击了关于iShareIntent about_iShare_intent = new Intent();about_iShare_intent.setClass(mActivity, AboutIShare.class);  //创建intent对象,并指定跳转页面startActivity(about_iShare_intent);    //跳转到iShare介绍页面}}else{Toast.makeText(getActivity(), "请先登录!", Toast.LENGTH_LONG).show();}}}

——到这整个iShare项目就开发完成了,整个过程可能会有部分代码或者配置不是很完整,接下来将会分模块写一下整个项目的详细代码,以及如何运行整个项目 和运行的结果

Android——“i分享”APP开发Day11相关推荐

  1. Android——“i 分享”APP开发Day06

    继续上一篇的内容,写FindFragment.java文件,在上一篇的三个函数基础上基本就可以展示出热门内容了,接下来主要就是处理找人和找文按钮的事件 因为之后还需要实现找人的功能,所以要先给创建一个 ...

  2. Android兼容性系统app开发的一些探究

    Android兼容性系统app开发的一些探究 说明 起因 软件现状 需求 实现探究 第一点:软件兼容原则 第二点:软件实现方案 具体实现 说明 说明 本文是我根据自己开发期间项目需求探究的总结,里面有 ...

  3. 浅析女性导购分享APP开发的发展趋势

    随着智能手机使用人数的增加,传统PC网站失去了原先的优势,导购分享APP开发更具有便捷性,而导购分享APP开发已逐渐成为了移动电商的工具.数据中心监测数据显示,2016年第三季,中国网络购物交易规模达 ...

  4. android手机分享app,Android Pie如何快捷分享文件至特定App

    作为全球使用量最大的移动操作系统,Android系统一直通过积极听取用户反馈和建议不断更迭改善.事实上在Android系统中还有很多普通用户尚未发现或者经常被忽视的小技巧,本文就简单的介绍下Andro ...

  5. Android入门 简单app开发:为女友实现记录月经周期的app

    前言 寒假答应给女友做一个记录月经周期的app,由于我太vegetable,写的比较辣鸡,大家凑活着看(手动笑哭) 思路: 首先要跟大家说的是, android开发 要明白开发思想:逻辑和视图是分开的 ...

  6. Android短视频app开发中如何实现上下滑动切换效果

    在大部分短视频app开发中,都会在app内增加上下滑动切换视频的功能,即下滑切换到下一条短视频,上滑切回到上一条.这种机制可以给用户带来良好的视觉体验,云豹作为优秀的app源码供应商,在该效果的实现上 ...

  7. 基于Android的理财app开发,基于Android的个人理财系统的设计与实现.doc

    毕业论文(设计)题目: 基于Android的个人理财系统 ---设计与实现 学生姓名: 学 号: 专业班级: 计算机科学与技术092班 指导教师: 职称 副教授 指导教师: 职称 起止时间: 目 录 ...

  8. Android爱读app开发记录之一---Splash界面

    一.简单介绍        该APP是一款简单易用.界面美观且功能强大的语音阅读器,实现本地导入阅读(支持大文件).在线阅读.书签.跳转.日夜间模式.设置字体大小.设置书架/阅读界面背景等功能     ...

  9. Android互动直播APP开发入门笔记,吐血整理

    (6)B帧:前向后向双向预测编码帧 (7)GOP(Group of Picture):两个I帧之间的图像组,CDN缓存GOP做到直播秒开 常见的音频编码器:AAC.PCM.WAV.OGG 常见的封装格 ...

最新文章

  1. 智能+制造,聪明的公司都走上了智能制造的道路
  2. php 将换行符替换,PHP替换回车换行符的三种方法
  3. lt;备份gt;10月18日 DNS
  4. 第七章 脚本参数的传递
  5. 信息核心技术体系是通往信息世纪的中国门票
  6. DataReader不奇怪,该出手时就出手!
  7. ehcache memcache redis 三大缓存男高音
  8. java 设置头错误信息,错误:在node.js中发送标头后无法设置标头
  9. IntelliJ IDEA下project概念和module的概念解释
  10. 优化程序性能(CSAPP)
  11. 谷歌验证码(Recaptcha)对接教程
  12. 使用JS完成一个简单的计算器功能
  13. windows10安装adb/fastboot教程
  14. CentOS7安装杀毒软件ClamAV图形界面ClamTk
  15. Gitbub远程仓库的访问
  16. java五子棋音乐_五子棋加背景音乐
  17. 同时投掷两个不同面的骰子
  18. Cyclone Protocol 首次中文社区亮相AMA实录(精华)
  19. vue中后台管理登录后的token管理
  20. Java秒杀系统实战系列~数据库级别Sql的优化与代码的调整

热门文章

  1. Apollo学习(超详细)
  2. 【每日早报】201/10/28
  3. python汉诺塔递归并统计次数_Python之汉诺塔递归运算
  4. c语言窗口皮肤,MFC 界面美化 Skinmagic
  5. 材料计算:电催化系列2——隐式溶剂效应、恒电势方法、OER台阶图、催化火山图、布拜图
  6. 初级跑者的全马备战计划
  7. 数据恢复方法有哪些?如何恢复误删照片
  8. 深度盘点:时序预测之异常检测算法综述
  9. 外贸日历|2月海外营销日历
  10. JAVA 输入年份月份打印该月的日历