-
MainActivity
package com.e.myapplicationtest.activity; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager; import android.os.Bundle; import android.util.Log; import android.widget.TextView; import com.e.myapplicationtest.R; import com.e.myapplicationtest.fragment.MyPagerAdapter; import com.e.myapplicationtest.fragment.NewsFramgment1; import com.e.myapplicationtest.fragment.NewsFramgment2; import com.e.myapplicationtest.fragment.NewsFramgment3; import com.e.myapplicationtest.fragment.NewsFramgment4; import com.google.android.material.tabs.TabLayout; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private ViewPager mViewPager; private TabLayout tabLayout; private MyPagerAdapter myPagerAdapter; private List<String> titlelist = new ArrayList<String>(); private NewsFramgment1 nfragment1; private NewsFramgment2 nfragment2; private NewsFramgment3 nfragment3; private NewsFramgment4 nfragment4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { titlelist.add("爱情"); titlelist.add("励志"); titlelist.add("喜剧"); titlelist.add("我的"); nfragment1 = new NewsFramgment1(); nfragment2 = new NewsFramgment2(); nfragment3 = new NewsFramgment3(); nfragment4 = new NewsFramgment4(); ArrayList<Fragment> fragmntList = nw ArrayList<Fragment>();
fragmntList.add(nfragment1);
fragmntList.add(nfragment2);
fragmntList.add(nfragment3);
fragmntList.add(nfragment4);
mViewPager = (ViewPager) findViewById(R.id.viewpager);
tabLayout = (TabLayout) findViewById(R.id.tab_layout);
myPagerAdapter = new MyPagerAdapter(getSupportFragmentManager(),titlelist, fragmntList);
mViewPager.setAdapter(myPagerAdapter);
tabLayout.setupWithViewPager(mViewPager);
}
}
-
ShowNewsActivity
package com.e.myapplicationtest.activity;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
import com.e.myapplicationtest.R;
import com.e.myapplicationtest.bean.NewsBean;
import com.loopj.android.image.SmartImageView;
public class ShowNewsActivity extends AppCompatActivity {
TextView title,author,time,content;
SmartImageView imageView;
static BitmapFactory.Options opts;
Bitmap bitmap = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_show_news);
Intent intent = getIntent();
NewsBean newsBean = (NewsBean) intent.getExtras().getSerializable("NewsList");
// 显示子啊什么位置
title = (TextView) this.findViewById(R.id.title);
author = (TextView) this.findViewById(R.id.author);
time = (TextView) this.findViewById(R.id.time);
content = (TextView) this.findViewById(R.id.content);
imageView = (SmartImageView) this.findViewById(R.id.img_name);
// 获取数据
title.setText(newsBean.getTitle());
author.setText(newsBean.getAuthor());
time.setText(newsBean.getTime());
content.setText(newsBean.getContent());
imageView.setImageUrl("http//(ip地址):8080/Web1/TestServlet/img/"+newsBean.getImg_name(),R.drawable.newspic1);
}
}
-
NewsBean
package com.e.myapplicationtest.bean;
import java.io.Serializable;
public class NewsBean implements Serializable {
public int id;
public String title;
public String content;
public String img_url;
public String img_name;
public String big_img_name;
public String author;
public String time;
public int type_id;
private int status;
public NewsBean()
{
}
public NewsBean(int id, String title, String content, String img_url,
String img_name, String big_img_name, String author, String time,int type_id,int status) {
this.id = id;
this.title = title;
this.content = content;
this.img_url = img_url;
this.img_name = img_name;
this.big_img_name = big_img_name;
this.author = author;
this.time = time;
this.type_id = type_id;
this.status=status;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getImg_url() {
return img_url;
}
public void setImg_url(String img_url) {
this.img_url = img_url;
}
public String getImg_name() {
return img_name;
}
public void setImg_name(String img_name) {
this.img_name = img_name;
}
public String getBig_img_name() {
return big_img_name;
}
public void setBig_img_name(String big_img_name) {
this.big_img_name = big_img_name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public int getType_id() {
return type_id;
}
public void setType_id(int type_id) {
this.type_id = type_id;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
-
MyPagerAdapter
package com.e.myapplicationtest.fragment;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.ArrayList;
import java.util.List;
public class MyPagerAdapter extends FragmentPagerAdapter {
private List<String> titlelist;
private ArrayList<Fragment> fragmentList;
public MyPagerAdapter(FragmentManager fm, List<String> titlelist, ArrayList<Fragment> fragmentList) {
super(fm);
this.titlelist = titlelist;
this.fragmentList = fragmentList;
}
@NonNull
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentList.size();
}
@Nullable
@Override
public CharSequence getPageTitle(int position) {
return titlelist.get(position);
}
}
-
NewsFramgment1
package com.e.myapplicationtest.fragment;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
//import androidx.fragment.app.Fragment;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.e.myapplicationtest.R;
import com.e.myapplicationtest.activity.ShowNewsActivity;
import com.e.myapplicationtest.bean.NewsBean;
import com.e.myapplicationtest.tool.JsonParse;
import com.e.myapplicationtest.tool.NewsListAdapter;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import org.apache.http.Header;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Use the {@link NewsFramgment1#?newInstance} factory method to
* create an instance of this fragment.
*/
public class NewsFramgment1 extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
ListView listView = null;
List<NewsBean> newsLists = new ArrayList<NewsBean>();
AsyncHttpClient client = new AsyncHttpClient();//创建AsyncHttpClient实例
// ListView listView = null;
private View mMainView;
//显示新闻大图片代码
private ViewPager viewPager;
private ImageView[] tips;//提示性点点数组
private int[] images;//图片ID数组
private int[] image_tips;
private int currentPage = 0 ;
public Bitmap[] bmp = null;
public Bitmap[] bmp_tips = null;
public NewsFramgment1() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
// * @param param1 Parameter 1.
// * @param param2 Parameter 2.
* @return A new instance of fragment NewsFramgment1.
*/
// TODO: Rename and change types and number of parameters
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = getActivity().getLayoutInflater();
mMainView = inflater.inflate(R.layout.fragment_news_framgment1,(ViewGroup) getActivity().findViewById(R.id.viewpager),false);
showBigImages();
listView = (ListView) mMainView.findViewById(R.id.listview);
//使用GET方式请求
client.get("http://(ip地址):8080/Web1/TestServlet/NewsSL?typeId=1",new AsyncHttpResponseHandler(){
public void onSuccess(int i , org.apache.http.Header[] headers, byte[] bytes){
//请求成功
try {
String json = new String(bytes,"gbk");
newsLists = JsonParse.getNewsInfo(json);
if (newsLists == null){
Log.i("newsList","解析失败!");
}else {
NewsListAdapter adapter = new NewsListAdapter(getActivity(),newsLists,listView);
listView.setAdapter(adapter);
//新闻列表被选中监听,跳转到新闻详细页面
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent intent = new Intent(getActivity(), ShowNewsActivity.class);
NewsBean newsBean = newsLists.get(arg2);
Bundle bundle = new Bundle();
bundle.putSerializable("NewsList",newsBean);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onFailure(int i, org.apache.http.Header[] headers ,byte[] bytes,Throwable throwable){
}
});
}
private void showBigImages() {
viewPager =(ViewPager) mMainView.findViewById(R.id.viewpager1);
//存放点点的容器
LinearLayout tipsBox = (LinearLayout) mMainView.findViewById(R.id.tipsBox);
//初始化图片资源
images = new int[]{R.drawable.app7,R.drawable.app2,R.drawable.app6};
image_tips = new int[]{R.drawable.page, R.drawable.pagenow};
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPurgeable = true;
opts.inInputShareable = true;
bmp = new Bitmap[images.length];
for (int i = 0; i < images.length;i++){
InputStream is = this.getResources().openRawResource(images[i]);
bmp[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//小原点图片
bmp_tips = new Bitmap[image_tips.length];
for (int i = 0 ; i < image_tips.length;i++){
InputStream is = this.getResources().openRawResource(image_tips[i]);
bmp_tips[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//初始化 提示点点
tips = new ImageView[10];
for (int i = 0 ; i< images.length;i++){
ImageView img = new ImageView(getActivity());
img.setLayoutParams(new LinearLayout.LayoutParams(20,20));
tips[i] = img;
if (i == 0){
img.setImageBitmap(bmp_tips[1]);
}else {
img.setImageBitmap(bmp_tips[0]);
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
params.leftMargin = 20;
params.rightMargin =20;
tipsBox.addView(img,params);
}
//初始化PagerAdapter
PagerAdapter adapter = new PagerAdapter() {
@Override
public int getCount() {
return images.length;
}
@Override
public boolean isViewFromObject(@NonNull View arg0, @NonNull Object arg1) {
return arg0 == arg1;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
ImageView im = new ImageView(getActivity());
im.setScaleType(ImageView.ScaleType.CENTER);
im.setImageBitmap(zoomImg(bmp[position],680,420));
container.addView(im);
return im;
}
};
viewPager.setAdapter(adapter);
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
Log.e("rf",String.valueOf(position));
tips[currentPage].setImageBitmap(bmp_tips[0]);
currentPage = position;
tips[currentPage].setImageBitmap(bmp_tips[1]);
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
private Bitmap zoomImg(Bitmap bm,int newWidth,int newHeight) {
//获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
//计算缩放比例
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
//取得想要缩放的matrix参数
Matrix martix = new Matrix();
martix.postScale(scaleWidth,scaleHeight);
//取得新的图片,www.2cto.com
Bitmap newbm = Bitmap.createBitmap(bm,0,0,width,height,martix,true);
return newbm;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup p = (ViewGroup) mMainView.getParent();
if (p!=null) {
p.removeAllViewsInLayout();
}
return mMainView;
}
}
-
NewsFramgment2
package com.e.myapplicationtest.fragment;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.e.myapplicationtest.R;
import com.e.myapplicationtest.activity.ShowNewsActivity;
import com.e.myapplicationtest.bean.NewsBean;
import com.e.myapplicationtest.tool.JsonParse;
import com.e.myapplicationtest.tool.NewsListAdapter;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Use the {@link NewsFramgment2#?newInstance} factory method to
* create an instance of this fragment.
*/
public class NewsFramgment2 extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
ListView listView = null;
List<NewsBean> newsLists = new ArrayList<NewsBean>();
AsyncHttpClient client = new AsyncHttpClient();//创建AsyncHttpClient实例
// ListView listView = null;
private View mMainView;
//显示新闻大图片代码
private ViewPager viewPager;
private ImageView[] tips;//提示性点点数组
private int[] images;//图片ID数组
private int[] image_tips;
private int currentPage = 0 ;
public Bitmap[] bmp = null;
public Bitmap[] bmp_tips = null;
public NewsFramgment2() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
// * @param param1 Parameter 1.
// * @param param2 Parameter 2.
* @return A new instance of fragment NewsFramgment1.
*/
// TODO: Rename and change types and number of parameters
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = getActivity().getLayoutInflater();
mMainView = inflater.inflate(R.layout.fragment_news_framgment2,(ViewGroup) getActivity().findViewById(R.id.viewpager),false);
showBigImages();
listView = (ListView) mMainView.findViewById(R.id.listview);
//使用GET方式请求
client.get("http://(ip地址):8080/Web1/TestServlet/NewsSL?typeId=2",new AsyncHttpResponseHandler(){
public void onSuccess(int i , org.apache.http.Header[] headers, byte[] bytes){
//请求成功
try {
String json = new String(bytes,"gbk");
newsLists = JsonParse.getNewsInfo(json);
if (newsLists == null){
Log.i("newsList","解析失败!");
}else {
NewsListAdapter adapter = new NewsListAdapter(getActivity(),newsLists,listView);
listView.setAdapter(adapter);
//新闻列表被选中监听,跳转到新闻详细页面
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent intent = new Intent(getActivity(), ShowNewsActivity.class);
NewsBean newsBean = newsLists.get(arg2);
Bundle bundle = new Bundle();
bundle.putSerializable("NewsList",newsBean);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onFailure(int i, org.apache.http.Header[] headers ,byte[] bytes,Throwable throwable){
}
});
}
private void showBigImages() {
viewPager =(ViewPager) mMainView.findViewById(R.id.viewpager2);
//存放点点的容器
LinearLayout tipsBox = (LinearLayout) mMainView.findViewById(R.id.tipsBox);
//初始化图片资源
images = new int[]{R.drawable.app9,R.drawable.app15,R.drawable.app5};
image_tips = new int[]{R.drawable.page, R.drawable.pagenow};
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPurgeable = true;
opts.inInputShareable = true;
bmp = new Bitmap[images.length];
for (int i = 0; i < images.length;i++){
InputStream is = this.getResources().openRawResource(images[i]);
bmp[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//小原点图片
bmp_tips = new Bitmap[image_tips.length];
for (int i = 0 ; i < image_tips.length;i++){
InputStream is = this.getResources().openRawResource(image_tips[i]);
bmp_tips[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//初始化 提示点点
tips = new ImageView[5];
for (int i = 0 ; i< images.length;i++){
ImageView img = new ImageView(getActivity());
img.setLayoutParams(new LinearLayout.LayoutParams(20,20));
tips[i] = img;
if (i == 0){
img.setImageBitmap(bmp_tips[1]);
}else {
img.setImageBitmap(bmp_tips[0]);
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
params.leftMargin = 20;
params.rightMargin =20;
tipsBox.addView(img,params);
}
//初始化PagerAdapter
PagerAdapter adapter = new PagerAdapter() {
@Override
public int getCount() {
return images.length;
}
@Override
public boolean isViewFromObject(@NonNull View arg0, @NonNull Object arg1) {
return arg0 == arg1;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
ImageView im = new ImageView(getActivity());
im.setScaleType(ImageView.ScaleType.CENTER);
im.setImageBitmap(zoomImg(bmp[position],680,420));
container.addView(im);
return im;
}
};
viewPager.setAdapter(adapter);
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
Log.e("rf",String.valueOf(position));
tips[currentPage].setImageBitmap(bmp_tips[0]);
currentPage = position;
tips[currentPage].setImageBitmap(bmp_tips[1]);
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
private Bitmap zoomImg(Bitmap bm,int newWidth,int newHeight) {
//获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
//计算缩放比例
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
//取得想要缩放的matrix参数
Matrix martix = new Matrix();
martix.postScale(scaleWidth,scaleHeight);
//取得新的图片,www.2cto.com
Bitmap newbm = Bitmap.createBitmap(bm,0,0,width,height,martix,true);
return newbm;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup p = (ViewGroup) mMainView.getParent();
if (p!=null) {
p.removeAllViewsInLayout();
}
return mMainView;
}
}
-
NewsFramgment3
package com.e.myapplicationtest.fragment;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
//import androidx.fragment.app.Fragment;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.e.myapplicationtest.R;
import com.e.myapplicationtest.activity.ShowNewsActivity;
import com.e.myapplicationtest.bean.NewsBean;
import com.e.myapplicationtest.tool.JsonParse;
import com.e.myapplicationtest.tool.NewsListAdapter;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Use the {@link NewsFramgment3#?newInstance} factory method to
* create an instance of this fragment.
*/
public class NewsFramgment3 extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
ListView listView = null;
List<NewsBean> newsLists = new ArrayList<NewsBean>();
AsyncHttpClient client = new AsyncHttpClient();//创建AsyncHttpClient实例
// ListView listView = null;
private View mMainView;
//显示新闻大图片代码
private ViewPager viewPager;
private ImageView[] tips;//提示性点点数组
private int[] images;//图片ID数组
private int[] image_tips;
private int currentPage = 0 ;
public Bitmap[] bmp = null;
public Bitmap[] bmp_tips = null;
public NewsFramgment3() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
// * @param param1 Parameter 1.
// * @param param2 Parameter 2.
* @return A new instance of fragment NewsFramgment1.
*/
// TODO: Rename and change types and number of parameters
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = getActivity().getLayoutInflater();
mMainView = inflater.inflate(R.layout.fragment_news_framgment3,(ViewGroup) getActivity().findViewById(R.id.viewpager),false);
showBigImages();
listView = (ListView) mMainView.findViewById(R.id.listview);
//使用GET方式请求
client.get("http://(ip地址):8080/Web1/TestServlet/NewsSL?typeId=3",new AsyncHttpResponseHandler(){
public void onSuccess(int i , org.apache.http.Header[] headers, byte[] bytes){
//请求成功
try {
String json = new String(bytes,"gbk");
newsLists = JsonParse.getNewsInfo(json);
if (newsLists == null){
Log.i("newsList","解析失败!");
}else {
NewsListAdapter adapter = new NewsListAdapter(getActivity(),newsLists,listView);
listView.setAdapter(adapter);
//新闻列表被选中监听,跳转到新闻详细页面
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent intent = new Intent(getActivity(), ShowNewsActivity.class);
NewsBean newsBean = newsLists.get(arg2);
Bundle bundle = new Bundle();
bundle.putSerializable("NewsList",newsBean);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onFailure(int i, org.apache.http.Header[] headers ,byte[] bytes,Throwable throwable){
}
});
}
private void showBigImages() {
viewPager =(ViewPager) mMainView.findViewById(R.id.viewpager3);
//存放点点的容器
LinearLayout tipsBox = (LinearLayout) mMainView.findViewById(R.id.tipsBox);
//初始化图片资源
images = new int[]{R.drawable.app13,R.drawable.app14,R.drawable.app11};
image_tips = new int[]{R.drawable.page, R.drawable.pagenow};
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPurgeable = true;
opts.inInputShareable = true;
bmp = new Bitmap[images.length];
for (int i = 0; i < images.length;i++){
InputStream is = this.getResources().openRawResource(images[i]);
bmp[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//小原点图片
bmp_tips = new Bitmap[image_tips.length];
for (int i = 0 ; i < image_tips.length;i++){
InputStream is = this.getResources().openRawResource(image_tips[i]);
bmp_tips[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//初始化 提示点点
tips = new ImageView[5];
for (int i = 0 ; i< images.length;i++){
ImageView img = new ImageView(getActivity());
img.setLayoutParams(new LinearLayout.LayoutParams(20,20));
tips[i] = img;
if (i == 0){
img.setImageBitmap(bmp_tips[1]);
}else {
img.setImageBitmap(bmp_tips[0]);
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
params.leftMargin = 20;
params.rightMargin =20;
tipsBox.addView(img,params);
}
//初始化PagerAdapter
PagerAdapter adapter = new PagerAdapter() {
@Override
public int getCount() {
return images.length;
}
@Override
public boolean isViewFromObject(@NonNull View arg0, @NonNull Object arg1) {
return arg0 == arg1;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
ImageView im = new ImageView(getActivity());
im.setScaleType(ImageView.ScaleType.CENTER);
im.setImageBitmap(zoomImg(bmp[position],680,420));
container.addView(im);
return im;
}
};
viewPager.setAdapter(adapter);
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
Log.e("rf",String.valueOf(position));
tips[currentPage].setImageBitmap(bmp_tips[0]);
currentPage = position;
tips[currentPage].setImageBitmap(bmp_tips[1]);
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
private Bitmap zoomImg(Bitmap bm,int newWidth,int newHeight) {
//获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
//计算缩放比例
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
//取得想要缩放的matrix参数
Matrix martix = new Matrix();
martix.postScale(scaleWidth,scaleHeight);
//取得新的图片,www.2cto.com
Bitmap newbm = Bitmap.createBitmap(bm,0,0,width,height,martix,true);
return newbm;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup p = (ViewGroup) mMainView.getParent();
if (p!=null) {
p.removeAllViewsInLayout();
}
return mMainView;
}
}
-
NewsFramgment4
package com.e.myapplicationtest.fragment;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
//import androidx.fragment.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.e.myapplicationtest.R;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import java.io.InputStream;
/**
* A simple {@link Fragment} subclass.
* Use the {@link NewsFramgment4#?newInstance} factory method to
* create an instance of this fragment.
*/
public class NewsFramgment4 extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
ListView listView = null;
private View mMainView;
//显示新闻大图片代码
private ViewPager viewPager;
private ImageView[] tips;//提示性点点数组
private int[] images;//图片ID数组
private int[] image_tips;
private int currentPage = 0 ;
public Bitmap[] bmp = null;
public Bitmap[] bmp_tips = null;
public NewsFramgment4() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
// * @param param1 Parameter 1.
// * @param param2 Parameter 2.
* @return A new instance of fragment NewsFramgment1.
*/
// TODO: Rename and change types and number of parameters
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LayoutInflater inflater = getActivity().getLayoutInflater();
mMainView = inflater.inflate(R.layout.fragment_news_framgment4,(ViewGroup) getActivity().findViewById(R.id.viewpager),false);
showBigImages();
// listView = (ListView) mMainView.findViewById(R.id.listview);
}
private void showBigImages() {
viewPager =(ViewPager) mMainView.findViewById(R.id.viewpager4);
//存放点点的容器
LinearLayout tipsBox = (LinearLayout) mMainView.findViewById(R.id.tipsBox);
//初始化图片资源
images = new int[]{R.drawable.app10,R.drawable.app11,R.drawable.app12,R.drawable.app13,R.drawable.app14};
image_tips = new int[]{R.drawable.page, R.drawable.pagenow};
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inPreferredConfig = Bitmap.Config.RGB_565;
opts.inPurgeable = true;
opts.inInputShareable = true;
bmp = new Bitmap[images.length];
for (int i = 0; i < images.length;i++){
InputStream is = this.getResources().openRawResource(images[i]);
bmp[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//小原点图片
bmp_tips = new Bitmap[images.length];
for (int i = 0 ; i < image_tips.length;i++){
InputStream is = this.getResources().openRawResource(images[i]);
bmp_tips[i] = BitmapFactory.decodeStream(is,null,opts);//将普通图片转换成位图
}
//初始化 提示点点
tips = new ImageView[7];
for (int i = 0 ; i< images.length;i++){
ImageView img = new ImageView(getActivity());
img.setLayoutParams(new LinearLayout.LayoutParams(20,20));
tips[i] = img;
if (i == 0){
img.setImageBitmap(bmp_tips[1]);
}else {
img.setImageBitmap(bmp_tips[0]);
}
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
params.leftMargin = 20;
params.rightMargin =20;
tipsBox.addView(img,params);
}
//初始化PagerAdapter
PagerAdapter adapter = new PagerAdapter() {
@Override
public int getCount() {
return images.length;
}
@Override
public boolean isViewFromObject(@NonNull View arg0, @NonNull Object arg1) {
return arg0 == arg1;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
ImageView im = new ImageView(getActivity());
im.setScaleType(ImageView.ScaleType.CENTER);
im.setImageBitmap(zoomImg(bmp[position],680,420));
container.addView(im);
return im;
}
};
viewPager.setAdapter(adapter);
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
Log.e("rf",String.valueOf(position));
tips[currentPage].setImageBitmap(bmp_tips[0]);
currentPage = position;
tips[currentPage].setImageBitmap(bmp_tips[1]);
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
});
}
private Bitmap zoomImg(Bitmap bm,int newWidth,int newHeight) {
//获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
//计算缩放比例
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
//取得想要缩放的matrix参数
Matrix martix = new Matrix();
martix.postScale(scaleWidth,scaleHeight);
//取得新的图片,www.2cto.com
Bitmap newbm = Bitmap.createBitmap(bm,0,0,width,height,martix,true);
return newbm;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup p = (ViewGroup) mMainView.getParent();
if (p!=null) {
p.removeAllViewsInLayout();
}
return mMainView;
}
}
-
JsonParse
package com.e.myapplicationtest.tool;
import com.e.myapplicationtest.bean.NewsBean;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import java.util.List;
public class JsonParse {
public static List<NewsBean> getNewsInfo(String json){
//使用gson库解析json数据
Gson gson = new Gson();
//创建一个TypeToken的匿名子类对象,并调用对象的getType()方法
Type listType = new TypeToken<List<NewsBean>>(){}.getType();
//把获取到的信息集合存到newsInfos中
List<NewsBean> newsInfos = gson.fromJson(json,listType);
return newsInfos;
}
}
-
NewsListAdapter
package com.e.myapplicationtest.tool;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.e.myapplicationtest.R;
import com.e.myapplicationtest.bean.NewsBean;
import com.google.android.material.transition.Hold;
import com.loopj.android.image.SmartImageView;
import org.w3c.dom.Text;
import java.util.List;
import java.util.logging.Handler;
public class NewsListAdapter extends ArrayAdapter<NewsBean> {
private ListView listView;
private LayoutInflater inflater;
private Context context;
Holder holder = null;
// String imgUrl ="";//存储图片的地址
public NewsListAdapter(Activity activity, List<NewsBean> newsBeans,ListView listView) {
super(activity,0,newsBeans);
this.listView = listView;
//得到一个渲染对象
inflater = activity.getLayoutInflater();
this.context = activity;
holder = new Holder();
}
public View getView(int position, View convertView, ViewGroup parent){
if (convertView == null){
convertView = inflater.inflate(R.layout.news,null);
holder.img = (SmartImageView)convertView.findViewById(R.id.img);
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.author = (TextView) convertView.findViewById(R.id.author);
holder.time = (TextView)convertView.findViewById(R.id.time);
convertView.setTag(holder);
}else {
holder = (Holder) convertView.getTag();
}
//获取item对应第几条(positon)的Model实体
NewsBean newsBean = getItem(position);
String imageUrl = "http://(ip地址):8080/Web1/TestServlet/img/"+newsBean.getImg_name();
System.out.println("imageUrl"+imageUrl);
holder.img.setTag(imageUrl);
holder.img.setImageUrl(imageUrl,R.drawable.icon);
holder.title.setText(newsBean.getTitle());
holder.author.setText(newsBean.getAuthor());
holder.time.setText(newsBean.getTime());
Log.i("text","position = "+position);
return convertView;
}
static class Holder{
SmartImageView img;
TextView title;
TextView author;
TextView time;
}
}
- activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.MainActivity"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/my_red"
app:tabTextColor="@color/black" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
- activity_show_news.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ShowNewsActivity">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_title_bar" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="电影介绍"
android:textColor="#ffffff"
android:textSize="20sp" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_marginRight="18dp"
android:background="@drawable/ic_top_bar_category" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relativeLayout1"
android:orientation="vertical" >
<View
android:layout_width="fill_parent"
android:layout_height="1dip"
android:background="@drawable/ic_shelf_category_divider" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:layout_marginTop="10dip"
android:textSize="20sp"
android:text="title"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="环球网" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_toRightOf="@+id/author"
android:text="2016-12-11 15:58" />
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginTop="8dp"
android:background="@drawable/ic_shelf_category_divider" />
<com.loopj.android.image.SmartImageView
android:id="@+id/img_name"
android:layout_width="300dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/newspic1" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="16dp"
android:padding="8dp">
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="content"
android:textSize="16sp" />
</ScrollView>
</LinearLayout>
</RelativeLayout>
- fragment_news_framgment1.xml
<?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"
tools:context=".fragment.NewsFramgment1"
android:orientation="vertical">
<!-- TODO: Update blank fragment layout -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager1"
android:layout_width="fill_parent"
android:layout_height="400px"
android:paddingLeft="5dp"
android:paddingRight="5dp">
</androidx.viewpager.widget.ViewPager>
<!-- 测换显示焦点图片底部的提示点-->
<RelativeLayout
android:id="@+id/tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="170dp">
<LinearLayout
android:id="@+id/tipsBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="@color/my_gray" />
<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
- fragment_news_framgment2.xml
<?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"
tools:context=".fragment.NewsFramgment2"
android:orientation="vertical">
<!-- TODO: Update blank fragment layout -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager2"
android:layout_width="fill_parent"
android:layout_height="400px"
android:paddingLeft="5dp"
android:paddingRight="5dp">
</androidx.viewpager.widget.ViewPager>
<!-- 测换显示焦点图片底部的提示点-->
<RelativeLayout
android:id="@+id/tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="170dp">
<LinearLayout
android:id="@+id/tipsBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="@color/my_gray" />
<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
- fragment_news_framgment3.xml
<?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"
tools:context=".fragment.NewsFramgment3"
android:orientation="vertical">
<!-- TODO: Update blank fragment layout -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager3"
android:layout_width="fill_parent"
android:layout_height="400px"
android:paddingLeft="5dp"
android:paddingRight="5dp">
</androidx.viewpager.widget.ViewPager>
<!-- 测换显示焦点图片底部的提示点-->
<RelativeLayout
android:id="@+id/tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="170dp">
<LinearLayout
android:id="@+id/tipsBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="@color/my_gray" />
<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
- fragment_news_framgment4.xml
<?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"
tools:context=".fragment.NewsFramgment4"
android:orientation="vertical">
<!-- TODO: Update blank fragment layout -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager4"
android:layout_width="fill_parent"
android:layout_height="300px"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginBottom="40dp">
</androidx.viewpager.widget.ViewPager>
<!-- 测换显示焦点图片底部的提示点-->
<RelativeLayout
android:id="@+id/tips"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp">
<LinearLayout
android:id="@+id/tipsBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
</FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="@color/my_gray" />
<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
- news.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="topic1"
android:textSize="18sp"
android:textStyle="bold"
/>
<com.loopj.android.image.SmartImageView
android:id="@+id/img"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/beijing"
/>
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:layout_alignLeft="@+id/title"
android:layout_marginTop="2dp"
android:text="凤凰新闻客户端"
android:textSize="12sp"/>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/author"
android:layout_alignParentRight="true"
android:layout_marginTop="2dp"
android:text="2022年5月20日"
android:textColor="#ff8247"
android:textSize="12sp"/>
</RelativeLayout>