首页 > 其他 > 详细

第二阶段(冲刺八)

时间:2020-06-02 00:47:37      阅读:55      评论:0      收藏:0      [点我收藏+]

实现数据显示

1.整体书籍展示

技术分享图片

 

2对应书籍章节展示

 

技术分享图片

 

 

showbookactivity

技术分享图片
package com.lh.std_everything.ui.home.hometype.studyshare.share;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lh.std_everything.R;

public class ShowBookActivity extends AppCompatActivity{
    public TextView textViewbookname,textViewbookauthor,textViewbookpublish,textViewbookusername;
    public ImageView bookphoto;
    public LinearLayout lin_tree;
    public Bundle bundle;
    public String arr[]={"begin","one","two","three","four","five","six","seven","eight","nine","ten","others"};
    public String harr[]={"heh","第一章","第二章","第三章","第四章","第五章","第六章","第七章","第八章","第九章","第十章","其他"};
    public Integer iarr[]={0,1,2,3,4,5,6,7,8,9,11};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_book);
        init();

        lin_tree.setOrientation(LinearLayout.VERTICAL);
        lin_tree.removeAllViews();
        if(bundle!=null)
        {
            for(int i=1;i<=11;i++)
            {
                if(bundle.containsKey(arr[i]))
                {
                    String key=bundle.getString(arr[i]);
                    TextView zhangjie=new TextView(this);
                    zhangjie.setText(harr[i]);
                    Log.i("章节展示:", ""+harr[i]);
                    zhangjie.setId(iarr[i]);
                    zhangjie.setTextSize(20);
                    zhangjie.setPadding(10,10,0,0);
                    lin_tree.addView(zhangjie);
                    zhangjie.setOnClickListener(v -> {
                        Bundle b1=new Bundle();
                        b1.putString("photos",key);
                        Intent intent =new Intent(ShowBookActivity.this,ShowBookAnswerActivity.class);
                        intent.putExtras(b1);
                        startActivity(intent);
                    });
                }
            }
        }
    }
    public void init()
    {
        textViewbookauthor=findViewById(R.id.tv_bookauthor);
        textViewbookname=findViewById(R.id.tv_bookname);
        textViewbookpublish=findViewById(R.id.tv_bookpublish);
        textViewbookusername=findViewById(R.id.tv_username);
        bookphoto=findViewById(R.id.bookphoto);
        lin_tree=findViewById(R.id.lin_tree);

        bundle = getIntent().getExtras();
        if(bundle!=null)
        {
            Log.i("接收端的bundle的username", bundle.getString("username"));
            textViewbookusername.setText("上传者:"+bundle.getString("username"));
            textViewbookpublish.setText("出版社:"+bundle.getString("bookpublish"));
            textViewbookname.setText(bundle.getString("bookname"));
            textViewbookauthor.setText("作者:"+bundle.getString("bookauthor"));
            String urls[]=bundle.getString("head").split("\\$");
            RequestOptions options = new RequestOptions()
                    .error(R.drawable.error)
                    .placeholder(R.drawable.loading);
            if(urls.length!=0) {
                for(int i=0;i<urls.length;i++)
                {
                    if(!urls[i].equals("null"))
                    {
                        Log.i("url",urls[i]);
                        Glide.with(this)
                                .load(urls[i])
                                .apply(options)
                                .into(bookphoto);
                        break;
                    }
                }
            }
        }
    }
}
View Code

 

3对应章节答案展示


技术分享图片

 

 showbookanswerActivity

技术分享图片
package com.lh.std_everything.ui.home.hometype.studyshare.share;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.lh.std_everything.R;
import com.lh.std_everything.ui.home.hometype.adapter.GridViewAdapter.GridViewAdapter;
import com.lh.std_everything.ui.home.hometype.news.shownews.ShowNewsActivity;
import com.lxj.xpopup.XPopup;

public class ShowBookAnswerActivity extends AppCompatActivity {
    public LinearLayout lin_imgs;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_book_answer);
        Bundle bundle = getIntent().getExtras();
        String urls[]=bundle.getString("photos").split("\\$");
        lin_imgs=findViewById(R.id.lin_imgs);
        RequestOptions options = new RequestOptions()
                .error(R.drawable.error)
                .placeholder(R.drawable.loading);
        if(urls.length!=0) {
            for(int i=0;i<urls.length;i++)
            {
                if(!urls[i].equals("null"))
                {
                    ImageView item=new ImageView(this);
                    Log.i("url",urls[i]);
                    Glide.with(this)
                            .load(urls[i])
                            .apply(options)
                            .into(item);
                    int finalI = i;
                    item.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            new XPopup.Builder(ShowBookAnswerActivity.this)
                                    .asImageViewer(item,urls[finalI],new GridViewAdapter.ImageLoader())
                                    .show();
                        }
                    });
                    lin_imgs.addView(item);
                }
            }
        }
    }
}
View Code

 

第二阶段(冲刺八)

原文:https://www.cnblogs.com/xlk3/p/13028538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!