Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make the main Framework of csdn app with Fragment,ViewPagerIndicator in Android

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Android uses Fragment,ViewPagerIndicator to make the main framework of csdn app. In view of this question, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Originally intended to download a CSDN client on the phone, nothing can browse the information, downloaded the official, found that it can not be used very well. Happened to find a csdn app written by God himself, downloaded and installed, felt very good, but also very smooth, basically met our daily browsing needs. App effect picture:

1. The layout file of the header. This is very simple:

An icon and title are displayed.

2. Main layout file:

A TabPageIndicator and a ViewPager.

3. Main Activity

TabAdapter.java

MainFragment.java

Package com.zhy.csdndemo; import android.annotation.SuppressLint; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @ SuppressLint ("ValidFragment") public class MainFragment extends Fragment {private int newsType = 0; public MainFragment (int newsType) {this.newsType = newsType @ Override public void onActivityCreated (Bundle savedInstanceState) {super.onActivityCreated (savedInstanceState);} @ Override public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View view = inflater.inflate (R.layout.tab_item_fragment_main, null); TextView tip = (TextView) view.findViewById (R.id.id_tip); tip.setText (TabAdapter.TITLES [newsType]) Return view;}}

4. Customize Theme in styles.xml

@ style/MyWidget.TabPageIndicator @ drawable/init_pic true 5000 @ null center @ drawable/vpi__tab_indicator 22dip 22dip 8dp 8dp @ style/MyTextAppearance.TabPageIndicator 16sp 1 bold @ color/black about Android using Fragment ViewPagerIndicator how to make csdn app main framework questions are shared here, I hope the above content can be of some help to you, if you still have a lot of doubts to solve, you can follow the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report