Android 实践:做一款新闻 APP

跟代码相关的工作,大多唯手熟尔,所以这里花了点时间做了款简易版的新闻 APP,虽然都是些基础的内容,不过还是可以加深自己对部分代码的理解。至少,可以加深自己的记忆


步骤


  1. 依赖库
  2. 网络请求
  3. 网络解析
  4. 界面布局
  5. 最后
  6. 运行界面
  7. 运行GIF
  8. 完整代码下载地址(github)

依赖库


过程中需要用到一些开源依赖库文件,先在 build.grade 中声明:

    compile 'com.google.code.gson:gson:2.8.0'       //网络解析
    compile 'com.squareup.okhttp3:okhttp:3.7.0'     //网络请求
    compile 'com.github.bumptech.glide:glide:3.8.0' //图片加载
    compile 'com.android.support:design:24.2.1'     //Material Design中用到的依赖库
    compile 'de.hdodenhof:circleimageview:2.1.0'    //显示圆形图片

网络请求


在包下创建一个文件夹 util 用来存放工具类,创建文件 HttpUtil.class 用来请求数据:

public class HttpUtil {
    public static void sendOkHttpRequest(String address, okhttp3.Callback callback){
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(address).build();
        client.newCall(request).enqueue(callback);
    }
}

这里用到的是 okhttp3.Callback 的回调接口,结果会返回到 callback 的回调函数中,后面会进行处理


网络解析


我们先从数据解析开始,毕竟这才是这个小项目的重点。这次项目使用的数据来源是天行数据(http://www.tianapi.com/ )的新闻资讯 API ,先看 API 的说明:

Android 实践:做一款新闻 APP_第1张图片

可以看到返回数据为 JSON, 默认返回 10 条参数。请求地址为:

这里写图片描述

其中, APIKEY 需要用个人的 API KEY 代替,可以在个人中心中看到,其他的请求地址也是大同小异

这里写图片描述

JSON 返回示例:

Android 实践:做一款新闻 APP_第2张图片

还有错误返回码,用来判断返回数据的异常情况:

Android 实践:做一款新闻 APP_第3张图片

根据 gson 的返回示例,我们可以写出对应的实体类文件,通过 gson 将返回数据转化为对应的类型。先创建一个 gson 文件夹存放实体类文件。

在 gson 文件夹下创建 New.class 文件:

public class News {
    @SerializedName("ctime")
    public String time;

    public String title;

    public String description;

    public String picUrl;

    public String url;

}

创建 NewsList.class 文件:

public class NewsList {

    public int code;

    public String msg;

    @SerializedName("newslist")
    public List newsList ;

}

至此,我们就已经创建好了与返回数据对应的实体类。

在 util 文件夹下创建文件 Utility.class 文件:

public class Utility {
    public static NewsList parseJsonWithGson(final String requestText){
        Gson gson = new Gson();
        return gson.fromJson(requestText, NewsList.class);
    }

}

将请求得到的数据解析为 NewList 实体类对象。现在网络请求和解析都准备好了,就开始界面文件了


界面布局


修改 values 目录下的 styles.xml 文件:

<resources>
    
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        -- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary
        "colorPrimaryDark">@color/colorPrimary
        "colorAccent">@color/colorAccent
    style>

resources>

修改通知栏颜色和标题栏颜色一样,是处于视觉统一的原因,也可以不修改(非必须)


主要采用的是 Material Design 的设计,整体布局采用的是滑动菜单,主界面内容为 ToolBar 和 ListView(这里为了方便,就直接使用),侧边栏内容为 NavigationView


主界面:
因为要用 ToolBar 替代 ActionBar, 我们先修改 values 下面的 styles 文件,修改主题为:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

在layout 下创建 nav_header 文件


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="180dp"
    android:background="@color/colorPrimary"
    android:padding="10dp">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/icon_image"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerInParent="true"
        android:src="@drawable/nav_icon" />

    <TextView
        android:id="@+id/username"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="https://github.com/lentitude"
        android:textColor="@color/color_White"
        android:textSize="14sp" />


    <TextView
        android:id="@+id/mail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/username"
        android:text="lentitude"
        android:textColor="@color/color_White"
        android:textSize="14sp" />

RelativeLayout>

这里在头部文件中放置了一个CircleImageView,两个 TextView,没有什么理解难度


在 res 目录下创建 menu 文件夹,新建 nav_menu.xml 文件:

version="1.0" encoding="utf-8"?>
"http://schemas.android.com/apk/res/android">
    "single">
        <item
            android:id="@+id/nav_society"
            android:title="社会新闻" />
        <item
            android:id="@+id/nav_county"
            android:title="国内新闻" />
        <item
            android:id="@+id/nav_internation"
            android:title="国际新闻" />
        <item
            android:id="@+id/nav_fun"
            android:title="娱乐新闻" />
        <item
            android:id="@+id/nav_sport"
            android:title="体育新闻" />
        <item
            android:id="@+id/nav_nba"
            android:title="NBA新闻" />
        <item
            android:id="@+id/nav_football"
            android:title="足球新闻" />
        <item
            android:id="@+id/nav_technology"
            android:title="科技新闻" />
        <item
            android:id="@+id/nav_work"
            android:title="创业新闻" />
        <item
            android:id="@+id/nav_apple"
            android:title="苹果新闻" />
        <item
            android:id="@+id/nav_war"
            android:title="军事新闻" />
        <item
            android:id="@+id/nav_internet"
            android:title="移动互联" />
        <item
            android:id="@+id/nav_travel"
            android:title="旅游咨询" />
        <item
            android:id="@+id/nav_health"
            android:title="健康知识" />
        <item
            android:id="@+id/nav_strange"
            android:title="奇闻异事" />
        <item
            android:id="@+id/nav_looker"
            android:title="美女图片" />
        <item
            android:id="@+id/nav_vr"
            android:title="VR科技" />
        <item
            android:id="@+id/nav_it"
            android:title="IT资讯" />


    

这里创建了若干个 ITEM 子项,只有 title,没有 icon,大家可以自行放置

主界面 activity_main.xml:

"1.0" encoding="utf-8"?>
.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    .support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        .support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            .support.v7.widget.Toolbar
                android:id="@+id/tool_bar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:contentInsetStart="0dp"
                app:titleTextColor="@color/color_White"
                android:background="@color/colorPrimary"
                />


        .support.design.widget.AppBarLayout>


        .support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipe_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            "@+id/list_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:divider="@color/color_Background"
                android:dividerHeight="1dp"

                />


        .support.v4.widget.SwipeRefreshLayout>

    .support.design.widget.CoordinatorLayout>


    .support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/nav_menu"
        />


.support.v4.widget.DrawerLayout>

因为是一步到位,所以……大家最好之前用过使用过相同的布局设计(比如:第一行代码)

DrawerLayout 中有两个直接子布局文件:
1. CoordinatorLayout:一种 FrameLayout, 作为显示主界面内容的最外层布局
2. NavigationView:作为显示侧边栏的最外层布局,不过已经封装好了,可以直接通过 app:headerLayout 和 app:menu 属性引用之前我们已经写好的 头部和菜单布局文件

CoordinatorLayout 中有两个直接子布局文件:
1. AppBarLayout :通过 AppBarLayout 属性,可以将 ToolBar 和 ListView 分隔开,可以对滚动事件进行响应,实现 Material 效果
2. SwipeRefreshLayout:用来刷新 ListView 中的内容

创建 list_view_item.xml 文件,设计 ListView 的子项布局:


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="@color/color_White">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp">

        <ImageView
            android:id="@+id/title_pic"
            android:layout_width="80dp"
            android:layout_height="60dp"
            android:layout_centerVertical="true"
            android:layout_alignParentRight="true"
            android:scaleType="centerCrop"/>

        <TextView
            android:id="@+id/title_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16sp"
            android:layout_marginRight="10dp"
            android:layout_alignTop="@+id/title_pic"
            android:layout_alignParentLeft="true"
            android:layout_toLeftOf="@+id/title_pic"
            />

        <TextView
            android:id="@+id/descr_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="8sp"
            android:layout_marginRight="10dp"
            android:layout_alignBottom="@+id/title_pic"
            android:layout_alignParentLeft="true"
            />

    RelativeLayout>


RelativeLayout>

子项布局内包含 3 个控件,ImageView 显示返回的图片,TextView 显示返回的标题和出处

创建一个 Title.class类:

public class Title {
    private String title;
    private String descr;
    private String imageUrl;
    private String uri;

    public Title(String title,String descr, String imageUrl, String uri){
        this.title = title;
        this.imageUrl = imageUrl;
        this.descr = descr;
        this.uri = uri;
    }

    public String getTitle() {
        return title;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public String getDescr() {
        return descr;
    }

    public String getUri() {
        return uri;
    }
}

这里之所以除了 标题,出处,图片显示在 ListViw 中,uri 传入另一个布局,显示内容文件

接下来就是 TitleAdapter.class

public class TitleAdapter extends ArrayAdapter<Title> {
    private int resourceId;

    public TitleAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List objects) {
        <span class="hljs-keyword">super</span>(context, resource, objects);
        resourceId = resource;
    }

    <span class="hljs-annotation">@NonNull</span>
    <span class="hljs-annotation">@Override</span>
    public View getView(int position, <span class="hljs-annotation">@Nullable</span> View convertView, <span class="hljs-annotation">@NonNull</span> ViewGroup parent) {
        Title title = getItem(position);
        View view;
        ViewHolder viewHolder;
        <span class="hljs-javadoc">/**
         * 缓存布局和实例,优化 listView
         */</span>
        <span class="hljs-keyword">if</span> (convertView == <span class="hljs-keyword">null</span>){
            view = LayoutInflater.from(getContext()).inflate(resourceId,parent,<span class="hljs-keyword">false</span>);
            viewHolder = <span class="hljs-keyword">new</span> ViewHolder();
            viewHolder.titleText = (TextView)view.findViewById(R.id.title_text);
            viewHolder.titlePic = (ImageView) view.findViewById(R.id.title_pic);
            viewHolder.titleDescr = (TextView)view.findViewById(R.id.descr_text);
            view.setTag(viewHolder);
        }<span class="hljs-keyword">else</span>{
            view = convertView;
            viewHolder = (ViewHolder) view.getTag();
        }

        Glide.<span class="hljs-keyword">with</span>(getContext()).load(title.getImageUrl()).into(viewHolder.titlePic);
        viewHolder.titleText.setText(title.getTitle());
        viewHolder.titleDescr.setText(title.getDescr());

        <span class="hljs-keyword">return</span> view;

    }

    public <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ViewHolder</span>{</span>
        TextView titleText;
        TextView titleDescr;
        ImageView titlePic;
    }
}
</code></pre> 
  <p>这里还是一样的老套路,通过convertView 来缓存布局,通过类 ViewHolder 缓存控件实例,这样做,可以节省 50% 的效率,所以还是按照老套路走吧。</p> 
  <p>接下来就是 Activity 文件 MainActivity.class:</p> 
  <pre class="prettyprint"><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MainActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">AppCompatActivity</span> {</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_SOCIETY= <span class="hljs-number">1</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_COUNTY= <span class="hljs-number">2</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_INTERNATION= <span class="hljs-number">3</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_FUN= <span class="hljs-number">4</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_SPORT= <span class="hljs-number">5</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_NBA= <span class="hljs-number">6</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_FOOTBALL= <span class="hljs-number">7</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_TECHNOLOGY= <span class="hljs-number">8</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_WORK= <span class="hljs-number">9</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_APPLE= <span class="hljs-number">10</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_WAR= <span class="hljs-number">11</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_INTERNET= <span class="hljs-number">12</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_TREVAL= <span class="hljs-number">13</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_HEALTH= <span class="hljs-number">14</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_STRANGE= <span class="hljs-number">15</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_LOOKER= <span class="hljs-number">16</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_VR= <span class="hljs-number">17</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span>  ITEM_IT= <span class="hljs-number">18</span>;


    <span class="hljs-keyword">private</span> List<Title> titleList = <span class="hljs-keyword">new</span> ArrayList<Title>();
    <span class="hljs-keyword">private</span> ListView listView;
    <span class="hljs-keyword">private</span> TitleAdapter adapter;
    <span class="hljs-keyword">private</span> NavigationView navigationView;
    <span class="hljs-keyword">private</span> DrawerLayout drawerLayout;
    <span class="hljs-keyword">private</span> SwipeRefreshLayout refreshLayout;


    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">protected</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onCreate</span>(Bundle savedInstanceState) {
        <span class="hljs-keyword">super</span>.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar)findViewById(R.id.tool_bar);
        setSupportActionBar(toolbar);
        <span class="hljs-keyword">final</span> ActionBar actionBar = getSupportActionBar();
        <span class="hljs-keyword">if</span> (actionBar != <span class="hljs-keyword">null</span>){
            actionBar.setDisplayHomeAsUpEnabled(<span class="hljs-keyword">true</span>);
            actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
        }
        actionBar.setDisplayShowTitleEnabled(<span class="hljs-keyword">true</span>);
        actionBar.setTitle(<span class="hljs-string">"社会新闻"</span>);

        refreshLayout = (SwipeRefreshLayout)findViewById(R.id.swipe_layout);
        refreshLayout.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
        listView = (ListView)findViewById(R.id.list_view);
        adapter = <span class="hljs-keyword">new</span> TitleAdapter(<span class="hljs-keyword">this</span>,R.layout.list_view_item, titleList);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(<span class="hljs-keyword">new</span> AdapterView.OnItemClickListener() {
            Intent intent = <span class="hljs-keyword">new</span> Intent(MainActivity.<span class="hljs-keyword">this</span>, ContentActivity.class);
            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onItemClick</span>(AdapterView<?> parent, View view, <span class="hljs-keyword">int</span> position, <span class="hljs-keyword">long</span> id) {
                Title title = titleList.get(position);
                intent.putExtra(<span class="hljs-string">"title"</span>,actionBar.getTitle());
                intent.putExtra(<span class="hljs-string">"uri"</span>,title.getUri());
                startActivity(intent);
            }
        });

        drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
        navigationView = (NavigationView)findViewById(R.id.nav_view);
        navigationView.setCheckedItem(R.id.nav_society);
        navigationView.setNavigationItemSelectedListener(<span class="hljs-keyword">new</span> NavigationView.OnNavigationItemSelectedListener() {
            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">onNavigationItemSelected</span>(@NonNull MenuItem item) {
                <span class="hljs-keyword">switch</span> (item.getItemId()){
                    <span class="hljs-keyword">case</span> R.id.nav_society:
                        handleCurrentPage(<span class="hljs-string">"社会新闻"</span>,ITEM_SOCIETY);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_county:
                        handleCurrentPage(<span class="hljs-string">"国内新闻"</span>,ITEM_COUNTY);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_internation:
                        handleCurrentPage(<span class="hljs-string">"国际新闻"</span>,ITEM_INTERNATION);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_fun:
                        handleCurrentPage(<span class="hljs-string">"娱乐新闻"</span>,ITEM_FUN);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_sport:
                        handleCurrentPage(<span class="hljs-string">"体育新闻"</span>,ITEM_SPORT);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_nba:
                        handleCurrentPage(<span class="hljs-string">"NBA新闻"</span>,ITEM_NBA);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_football:
                        handleCurrentPage(<span class="hljs-string">"足球新闻"</span>,ITEM_FOOTBALL);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_technology:
                        handleCurrentPage(<span class="hljs-string">"科技新闻"</span>,ITEM_TECHNOLOGY);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_work:
                        handleCurrentPage(<span class="hljs-string">"创业新闻"</span>,ITEM_WORK);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_apple:
                        handleCurrentPage(<span class="hljs-string">"苹果新闻"</span>,ITEM_APPLE);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_war:
                        handleCurrentPage(<span class="hljs-string">"军事新闻"</span>,ITEM_WAR);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_internet:
                        handleCurrentPage(<span class="hljs-string">"移动互联"</span>,ITEM_INTERNET);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_travel:
                        handleCurrentPage(<span class="hljs-string">"旅游资讯"</span>,ITEM_TREVAL);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_health:
                        handleCurrentPage(<span class="hljs-string">"健康知识"</span>,ITEM_HEALTH);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_strange:
                        handleCurrentPage(<span class="hljs-string">"奇闻异事"</span>,ITEM_STRANGE);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_looker:
                        handleCurrentPage(<span class="hljs-string">"美女图片"</span>,ITEM_LOOKER);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_vr:
                        handleCurrentPage(<span class="hljs-string">"VR科技"</span>,ITEM_VR);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">case</span> R.id.nav_it:
                        handleCurrentPage(<span class="hljs-string">"IT资讯"</span>,ITEM_IT);
                        <span class="hljs-keyword">break</span>;
                    <span class="hljs-keyword">default</span>:
                        <span class="hljs-keyword">break</span>;
                }
                drawerLayout.closeDrawers();
                <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
            }
        });

        refreshLayout.setOnRefreshListener(<span class="hljs-keyword">new</span> SwipeRefreshLayout.OnRefreshListener() {
            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onRefresh</span>() {
                refreshLayout.setRefreshing(<span class="hljs-keyword">true</span>);
                <span class="hljs-keyword">int</span> itemName = parseString((String)actionBar.getTitle());
                requestNew(itemName);
            }
        });

        requestNew(ITEM_SOCIETY);

    }

    <span class="hljs-javadoc">/**
     *  判断是否是当前页面,如果不是则 请求处理数据
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handleCurrentPage</span>(String text, <span class="hljs-keyword">int</span> item){
        ActionBar actionBar = getSupportActionBar();
        <span class="hljs-keyword">if</span> (!text.equals(actionBar.getTitle().toString())){
            actionBar.setTitle(text);
            requestNew(item);
            refreshLayout.setRefreshing(<span class="hljs-keyword">true</span>);
        }
    }


    <span class="hljs-javadoc">/**
     * 请求处理数据
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">requestNew</span>(<span class="hljs-keyword">int</span> itemName){

        <span class="hljs-comment">// 根据返回到的 URL 链接进行申请和返回数据</span>
        String address = response(itemName);    <span class="hljs-comment">// key</span>
        HttpUtil.sendOkHttpRequest(address, <span class="hljs-keyword">new</span> Callback() {
            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onFailure</span>(Call call, IOException e) {
                runOnUiThread(<span class="hljs-keyword">new</span> Runnable() {
                    <span class="hljs-annotation">@Override</span>
                    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span>() {
                        Toast.makeText(MainActivity.<span class="hljs-keyword">this</span>, <span class="hljs-string">"新闻加载失败"</span>, Toast.LENGTH_SHORT).show();
                    }
                });
            }

            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResponse</span>(Call call, Response response) <span class="hljs-keyword">throws</span> IOException {
                <span class="hljs-keyword">final</span> String responseText = response.body().string();
                <span class="hljs-keyword">final</span> NewsList newlist = Utility.parseJsonWithGson(responseText);
                <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> code = newlist.code;
                <span class="hljs-keyword">final</span> String msg = newlist.msg;
                <span class="hljs-keyword">if</span> (code == <span class="hljs-number">200</span>){
                    titleList.clear();
                    <span class="hljs-keyword">for</span> (News news:newlist.newsList){
                        Title title = <span class="hljs-keyword">new</span> Title(news.title,news.description,news.picUrl, news.url);
                        titleList.add(title);
                    }

                    runOnUiThread(<span class="hljs-keyword">new</span> Runnable() {
                        <span class="hljs-annotation">@Override</span>
                        <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span>() {
                            adapter.notifyDataSetChanged();
                            listView.setSelection(<span class="hljs-number">0</span>);
                            refreshLayout.setRefreshing(<span class="hljs-keyword">false</span>);
                        };
                    });
                }<span class="hljs-keyword">else</span>{
                    runOnUiThread(<span class="hljs-keyword">new</span> Runnable() {
                        <span class="hljs-annotation">@Override</span>
                        <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span>() {
                            Toast.makeText(MainActivity.<span class="hljs-keyword">this</span>, <span class="hljs-string">"数据错误返回"</span>,Toast.LENGTH_SHORT).show();
                            refreshLayout.setRefreshing(<span class="hljs-keyword">false</span>);
                        }
                    });
                }



            }
        });


    }

    <span class="hljs-javadoc">/**
     * 输入不同的类型选项,返回对应的 URL 链接
     */</span>
    <span class="hljs-keyword">private</span> String <span class="hljs-title">response</span>(<span class="hljs-keyword">int</span> itemName){
        String address = <span class="hljs-string">"https://api.tianapi.com/social/?key=339a8b166f397f008236e596616a5f54&num=50&rand=1"</span>;
        <span class="hljs-keyword">switch</span>(itemName){
            <span class="hljs-keyword">case</span> ITEM_SOCIETY:
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_COUNTY:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"guonei"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_INTERNATION:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"world"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_FUN:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"huabian"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_SPORT:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"tiyu"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_NBA:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"nba"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_FOOTBALL:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"football"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_TECHNOLOGY:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"keji"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_WORK:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"startup"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_APPLE:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"apple"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_WAR:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"military"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_INTERNET:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"mobile"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_TREVAL:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"travel"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_HEALTH:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"health"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_STRANGE:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"qiwen"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_LOOKER:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"meinv"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_VR:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"vr"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">case</span> ITEM_IT:
                address = address.replaceAll(<span class="hljs-string">"social"</span>,<span class="hljs-string">"it"</span>);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">default</span>:
        }
        <span class="hljs-keyword">return</span> address;
    }

    <span class="hljs-javadoc">/**
     * 通过 actionbar.getTitle() 的参数,返回对应的 ItemName
     */</span>
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> <span class="hljs-title">parseString</span>(String text){
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"社会新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_SOCIETY;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"国内新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_COUNTY;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"国际新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_INTERNATION;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"娱乐新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_FUN;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"体育新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_SPORT;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"NBA新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_NBA;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"足球新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_FOOTBALL;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"科技新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_TECHNOLOGY;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"创业新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_WORK;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"苹果新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_APPLE;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"军事新闻"</span>)){
            <span class="hljs-keyword">return</span> ITEM_WAR;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"移动互联"</span>)){
            <span class="hljs-keyword">return</span> ITEM_INTERNET;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"旅游资讯"</span>)){
            <span class="hljs-keyword">return</span> ITEM_TREVAL;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"健康知识"</span>)){
            <span class="hljs-keyword">return</span> ITEM_HEALTH;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"奇闻异事"</span>)){
            <span class="hljs-keyword">return</span> ITEM_STRANGE;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"美女图片"</span>)){
            <span class="hljs-keyword">return</span> ITEM_LOOKER;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"VR科技"</span>)){
            <span class="hljs-keyword">return</span> ITEM_VR;
        }
        <span class="hljs-keyword">if</span> (text.equals(<span class="hljs-string">"IT资讯"</span>)){
            <span class="hljs-keyword">return</span> ITEM_IT;
        }
        <span class="hljs-keyword">return</span> ITEM_SOCIETY;
    }

    <span class="hljs-javadoc">/**
     * 对侧边栏按钮进行处理,打开侧边栏
     */</span>
    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">onOptionsItemSelected</span>(MenuItem item) {
        <span class="hljs-keyword">switch</span> (item.getItemId()){
            <span class="hljs-keyword">case</span> android.R.id.home:
                drawerLayout.openDrawer(GravityCompat.START);
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">default</span>:
        }
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
    }

    <span class="hljs-javadoc">/**
     * 对返回键进行处理,如果侧边栏打开则关闭侧边栏,否则关闭 activity
     */</span>
    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onBackPressed</span>() {
        <span class="hljs-keyword">if</span>(drawerLayout.isDrawerOpen(GravityCompat.START)){
            drawerLayout.closeDrawers();
        }<span class="hljs-keyword">else</span>{
            finish();
        }
    }
}
</code></pre> 
  <p>本文的代码量虽然很大,只是比较繁琐,因为需要根据点击的 ITEM 来对不同的 接口地址提出申请,大部分的函数功能都有进行注释,所以略过了</p> 
  <pre class="prettyprint"><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">requestNew</span>(<span class="hljs-keyword">int</span> itemName){

        <span class="hljs-comment">// 根据返回到的 URL 链接进行申请和返回数据</span>
        String address = response(itemName);    <span class="hljs-comment">// key</span>
        HttpUtil.sendOkHttpRequest(address, <span class="hljs-keyword">new</span> Callback() {
            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onFailure</span>(Call call, IOException e) {
                runOnUiThread(<span class="hljs-keyword">new</span> Runnable() {
                    <span class="hljs-annotation">@Override</span>
                    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span>() {
                        Toast.makeText(MainActivity.<span class="hljs-keyword">this</span>, <span class="hljs-string">"新闻加载失败"</span>, Toast.LENGTH_SHORT).show();
                    }
                });
            }

            <span class="hljs-annotation">@Override</span>
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onResponse</span>(Call call, Response response) <span class="hljs-keyword">throws</span> IOException {
                <span class="hljs-keyword">final</span> String responseText = response.body().string();
                <span class="hljs-keyword">final</span> NewsList newlist = Utility.parseJsonWithGson(responseText);
                <span class="hljs-keyword">final</span> <span class="hljs-keyword">int</span> code = newlist.code;
                <span class="hljs-keyword">final</span> String msg = newlist.msg;
                <span class="hljs-keyword">if</span> (code == <span class="hljs-number">200</span>){
                    titleList.clear();
                    <span class="hljs-keyword">for</span> (News news:newlist.newsList){
                        Title title = <span class="hljs-keyword">new</span> Title(news.title,news.description,news.picUrl, news.url);
                        titleList.add(title);
                    }

                    runOnUiThread(<span class="hljs-keyword">new</span> Runnable() {
                        <span class="hljs-annotation">@Override</span>
                        <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span>() {
                            adapter.notifyDataSetChanged();
                            listView.setSelection(<span class="hljs-number">0</span>);
                            refreshLayout.setRefreshing(<span class="hljs-keyword">false</span>);
                        };
                    });
                }<span class="hljs-keyword">else</span>{
                    runOnUiThread(<span class="hljs-keyword">new</span> Runnable() {
                        <span class="hljs-annotation">@Override</span>
                        <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">run</span>() {
                            Toast.makeText(MainActivity.<span class="hljs-keyword">this</span>, <span class="hljs-string">"数据错误返回"</span>,Toast.LENGTH_SHORT).show();
                            refreshLayout.setRefreshing(<span class="hljs-keyword">false</span>);
                        }
                    });
                }



            }
        });


    }</code></pre> 
  <ol> 
   <li>外部调用时传入 itemName 参数,通过 response() 函数得到所需要请求数据的地址</li> 
   <li>通过sendOkHttpRequest() 回调方法,在返回数据成功的 onResponse() 方法中使用 parseJsonWithGson() 方法获取对应的实体类</li> 
   <li>将实体类中的数据添加到 Title对应中,将 Title 对象添加到 titleList 中,最后通过 runOnUiThread() 方法,切换到主线程提醒适配器进行数据更新。</li> 
  </ol> 
  <p>至此,主界面的代码逻辑都已经处理好了,还有 ListView 子项布局的点击事件处理:</p> 
  <pre class="prettyprint"><code class="hljs cs">listView.setOnItemClickListener(<span class="hljs-keyword">new</span> AdapterView.OnItemClickListener() {
            Intent intent = <span class="hljs-keyword">new</span> Intent(MainActivity.<span class="hljs-keyword">this</span>, ContentActivity.class);
            @Override
            <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onItemClick</span>(AdapterView<?> parent, View view, <span class="hljs-keyword">int</span> position, <span class="hljs-keyword">long</span> id) {
                Title title = titleList.<span class="hljs-keyword">get</span>(position);
                intent.putExtra(<span class="hljs-string">"title"</span>,actionBar.getTitle());
                intent.putExtra(<span class="hljs-string">"uri"</span>,title.getUri());
                startActivity(intent);
            }
        });</code></pre> 
  <p>在点击 ListView 子项布局时,会传入 标题栏文本 和 内容 URL</p> 
  <p>文件 activity_content.xml:</p> 
  <pre class="prettyprint"><code class="hljs avrasm"><?xml version=<span class="hljs-string">"1.0"</span> encoding=<span class="hljs-string">"utf-8"</span>?>
<android<span class="hljs-preprocessor">.support</span><span class="hljs-preprocessor">.design</span><span class="hljs-preprocessor">.widget</span><span class="hljs-preprocessor">.CoordinatorLayout</span>
    xmlns:android=<span class="hljs-string">"http://schemas.android.com/apk/res/android"</span>
    xmlns:app=<span class="hljs-string">"http://schemas.android.com/apk/res-auto"</span>
    android:layout_width=<span class="hljs-string">"match_parent"</span>
    android:layout_height=<span class="hljs-string">"match_parent"</span>
    android:background=<span class="hljs-string">"@color/color_White"</span>>

    <android<span class="hljs-preprocessor">.support</span><span class="hljs-preprocessor">.design</span><span class="hljs-preprocessor">.widget</span><span class="hljs-preprocessor">.AppBarLayout</span>
        android:layout_width=<span class="hljs-string">"match_parent"</span>
        android:layout_height=<span class="hljs-string">"wrap_content"</span>
        >

        <android<span class="hljs-preprocessor">.support</span><span class="hljs-preprocessor">.v</span>7<span class="hljs-preprocessor">.widget</span><span class="hljs-preprocessor">.Toolbar</span>
            android:id=<span class="hljs-string">"@+id/tool_bar"</span>
            android:layout_width=<span class="hljs-string">"match_parent"</span>
            android:layout_height=<span class="hljs-string">"?attr/actionBarSize"</span>
            app:titleTextColor=<span class="hljs-string">"@color/color_White"</span>
            app:theme=<span class="hljs-string">"@style/ThemeOverlay.AppCompat.Light"</span>
            app:layout_scrollFlags=<span class="hljs-string">"enterAlways|snap|scroll"</span>/>

    </android<span class="hljs-preprocessor">.support</span><span class="hljs-preprocessor">.design</span><span class="hljs-preprocessor">.widget</span><span class="hljs-preprocessor">.AppBarLayout</span>>


    <WebView
        android:id=<span class="hljs-string">"@+id/web_view"</span>
        android:layout_width=<span class="hljs-string">"match_parent"</span>
        android:layout_height=<span class="hljs-string">"match_parent"</span>
        app:layout_behavior=<span class="hljs-string">"@string/appbar_scrolling_view_behavior"</span>/>



</android<span class="hljs-preprocessor">.support</span><span class="hljs-preprocessor">.design</span><span class="hljs-preprocessor">.widget</span><span class="hljs-preprocessor">.CoordinatorLayout</span>>
</code></pre> 
  <p>如果了解了 activity_main.xml 的布局,这个布局也就没什么难度了,主要是新增了 WebView 控件,用来显示传入的 URL</p> 
  <p>文件 ContentActivity.class:</p> 
  <pre class="prettyprint"><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ContentActivity</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">AppCompatActivity</span> {</span>
    <span class="hljs-keyword">private</span> WebView webView;


    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">protected</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onCreate</span>(Bundle savedInstanceState) {
        <span class="hljs-keyword">super</span>.onCreate(savedInstanceState);
        setContentView(R.layout.activity_content);

        Toolbar toolbar = (Toolbar)findViewById(R.id.tool_bar);
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        <span class="hljs-keyword">if</span> (actionBar != <span class="hljs-keyword">null</span>){
            actionBar.setDisplayHomeAsUpEnabled(<span class="hljs-keyword">true</span>);
            actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
        }

        webView = (WebView)findViewById(R.id.web_view);
        webView.getSettings().setJavaScriptEnabled(<span class="hljs-keyword">true</span>);
        webView.setWebViewClient(<span class="hljs-keyword">new</span> WebViewClient());

        String uri = getIntent().getStringExtra(<span class="hljs-string">"uri"</span>);
        String title = getIntent().getStringExtra(<span class="hljs-string">"title"</span>);
        actionBar.setDisplayShowTitleEnabled(<span class="hljs-keyword">true</span>);
        actionBar.setTitle(title);
        webView.loadUrl(uri);

    }

    <span class="hljs-javadoc">/**
     * 点击返回键做了处理
     */</span>
    <span class="hljs-annotation">@Override</span>
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">onOptionsItemSelected</span>(MenuItem item) {
        <span class="hljs-keyword">switch</span> (item.getItemId()){
            <span class="hljs-keyword">case</span> android.R.id.home:
                finish();
                <span class="hljs-keyword">break</span>;
            <span class="hljs-keyword">default</span>:
        }
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
    }
}
</code></pre> 
  <p>显示传入的 URL网址</p> 
  <hr> 
  <p><strong>最后</strong></p> 
  <hr> 
  <p>到这里就结束了 ? 如果你认为都结束了,那你可以就需要面对打开应用之后马上闪退的情况了…….<strong>权限</strong> </p> 
  <p>我们还没有对权限进行申请,在 AndroidManifest 文件中添加声明:</p> 
  <pre class="prettyprint"><code class="hljs xml"><span class="hljs-tag"><<span class="hljs-title">uses-permission</span> <span class="hljs-attribute">android:name</span>=<span class="hljs-value">"android.permission.INTERNET"</span>/></span></code></pre> 
  <p>不过个人还是建议把 权限的考虑放在最先的优先级,毕竟养成这个习惯,就可以专注于代码的 bug…………………..</p> 
  <hr> 
  <p><strong>运行界面</strong></p> 
  <hr> 
  <p></p> 
  <center> 
   <a href="http://img.e-com-net.com/image/info8/09a2c7e4d26d48b0a7ffebe20c1fe389.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/09a2c7e4d26d48b0a7ffebe20c1fe389.jpg" alt="Android 实践:做一款新闻 APP_第4张图片" title="" width="301" height="532" style="border:1px solid black;"></a> 
   <br> (主界面) 
  </center> 
  <p></p> 
  <p></p> 
  <center> 
   <a href="http://img.e-com-net.com/image/info8/46113cfdcbb541978628956825d8b91b.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/46113cfdcbb541978628956825d8b91b.jpg" alt="Android 实践:做一款新闻 APP_第5张图片" title="" width="298" height="531" style="border:1px solid black;"></a> 
   <br> (侧边栏) 
  </center> 
  <p></p> 
  <p></p> 
  <center> 
   <a href="http://img.e-com-net.com/image/info8/d406e8b301f64462830cb0d5fb6cb189.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/d406e8b301f64462830cb0d5fb6cb189.jpg" alt="Android 实践:做一款新闻 APP_第6张图片" title="" width="302" height="535" style="border:1px solid black;"></a> 
   <br> (内容界面) 
  </center> 
  <p></p> 
  <hr> 
  <p><strong>运行 GIF</strong></p> 
  <hr> 
  <p></p> 
  <center>  
   <br> (由于大小限制,所以就只能传这么大了) 
  </center> 
  <p></p> 
  <hr> 
  <p><strong>完整代码下载地址</strong></p> 
  <hr> 
  <p>https://github.com/lentitude/NewsMD</p> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1292185866545995776"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(Android)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835513699826233344.htm"
                           title="android系统selinux中添加新属性property" target="_blank">android系统selinux中添加新属性property</a>
                        <span class="text-muted">辉色投像</span>

                        <div>1.定位/android/system/sepolicy/private/property_contexts声明属性开头:persist.charge声明属性类型:u:object_r:system_prop:s0图12.定位到android/system/sepolicy/public/domain.te删除neverallow{domain-init}default_prop:property</div>
                    </li>
                    <li><a href="/article/1835470119195734016.htm"
                           title="2.2.6 通知类控件 Toast、Menu" target="_blank">2.2.6 通知类控件 Toast、Menu</a>
                        <span class="text-muted">常思行</span>

                        <div>本文例程下载:WillFlow_Toast、WillFlowMenu一、什么是Toast?Toast也被叫做吐司,是Android系统提供的一种非常好的提醒方式,在程序中可以使用它将一些短小的信息通知给用户,它有如下两个特点:Toast是没有焦点的Toast显示的时间有限过一定的时间就会自动消失所以一般来讲Toast的使用并不会影响我们的正常操作,并且它通常不会占用太大的屏幕空间,有着良好的用户体</div>
                    </li>
                    <li><a href="/article/1835450889452744704.htm"
                           title="mac 备份android 手机通讯录导入iphone,iphone如何导出通讯录(轻松教你iPhone备份通讯录的方法)..." target="_blank">mac 备份android 手机通讯录导入iphone,iphone如何导出通讯录(轻松教你iPhone备份通讯录的方法)...</a>
                        <span class="text-muted">weixin_39762838</span>
<a class="tag" taget="_blank" href="/search/mac/1.htm">mac</a><a class="tag" taget="_blank" href="/search/%E5%A4%87%E4%BB%BDandroid/1.htm">备份android</a><a class="tag" taget="_blank" href="/search/%E6%89%8B%E6%9C%BA%E9%80%9A%E8%AE%AF%E5%BD%95%E5%AF%BC%E5%85%A5iphone/1.htm">手机通讯录导入iphone</a>
                        <div>在日新月异的手机更替中,换手机已经成为一个非常稀松平常的事情,但将旧手机上面的通讯录导入到新手机还是让不少小伙伴为难,本篇将给大家详细讲解这方面的知识:“苹果手机通讯录怎么导入到新手机”及“安卓手机通讯录导入到新手机”的方法。一、苹果手机通讯录导入到新手机常用方法(SIM卡导入)在苹果手机主频幕上找到“设置”,单击进入设置菜单,下拉菜单列表,点击“邮件、通讯录、日历”,然后找到“导入SIM卡通讯录</div>
                    </li>
                    <li><a href="/article/1835450511071997952.htm"
                           title="android 更改窗口的层次,浮窗开发之窗口层级" target="_blank">android 更改窗口的层次,浮窗开发之窗口层级</a>
                        <span class="text-muted">Ms.Bu</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/%E6%9B%B4%E6%94%B9%E7%AA%97%E5%8F%A3%E7%9A%84%E5%B1%82%E6%AC%A1/1.htm">更改窗口的层次</a>
                        <div>最近在项目中遇到了这样的需求:需要在特定的其他应用之上悬浮自己的UI交互(拖动、输入等复杂的UI交互),和九游的浮窗类似,不过我们的比九游的体验更好,我们越过了很多授权的限制。浮窗效果很多人都知道如何去实现一个简单的浮窗,但是却很少有人去深入的研究背后的流程机制,由于项目中浮窗交互比较复杂,遇到了些坑查看了很多资料,故总结浮窗涉及到的知识点:窗口层级关系(浮窗是如何“浮”的)?浮窗有哪些限制,如何</div>
                    </li>
                    <li><a href="/article/1835448619277316096.htm"
                           title="Android应用性能优化" target="_blank">Android应用性能优化</a>
                        <span class="text-muted">轻口味</span>
<a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a>
                        <div>Android手机由于其本身的后台机制和硬件特点,性能上一直被诟病,所以软件开发者对软件本身的性能优化就显得尤为重要;本文将对Android开发过程中性能优化的各个方面做一个回顾与总结。Cache优化ListView缓存:ListView中有一个回收器,Item滑出界面的时候View会回收到这里,需要显示新的Item的时候,就尽量重用回收器里面的View;每次在getView函数中inflate新</div>
                    </li>
                    <li><a href="/article/1835412764722556928.htm"
                           title="Android实现监听事件的方法" target="_blank">Android实现监听事件的方法</a>
                        <span class="text-muted">Amy木婉清</span>

                        <div>1.通过内部类实现2.通过匿名内部类实现3.通过事件源所在类实现4.通过外部类实现5.布局文件中onclick属性(针对点击事件)1.通过内部类实现代码:privateButtonmBtnEvent;//oncreate中mBtnEvent.setOnClickListener(newOnClick());//内部类实现监听classOnClickimplementsView.OnClickLis</div>
                    </li>
                    <li><a href="/article/1835400203130204160.htm"
                           title="高级UI<第二十四篇>:Android中用到的矩阵常识" target="_blank">高级UI<第二十四篇>:Android中用到的矩阵常识</a>
                        <span class="text-muted">NoBugException</span>

                        <div>(1)定义在数学中,矩阵(Matrix)是一个按照长方阵列排列的复数或实数集合。由m×n个数aij排成的m行n列的数表称为m行n列的矩阵,简称m×n矩阵。记作:图片.png这m×n个数称为矩阵A的元素,简称为元,数aij位于矩阵A的第i行第j列,称为矩阵A的(i,j)元,以数aij为(i,j)元的矩阵可记为(aij)或(aij)m×n,m×n矩阵A也记作Amn。元素是实数的矩阵称为实矩阵,元素是复</div>
                    </li>
                    <li><a href="/article/1835398694636187648.htm"
                           title="RK3229_Android9.0_Box 4G模块EC200A调试" target="_blank">RK3229_Android9.0_Box 4G模块EC200A调试</a>
                        <span class="text-muted">suifen_</span>
<a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a>
                        <div>0、kernel修改这部分完全可以参考Linux的移植:RK3588EC200A-CN【4G模块】调试_rkec200a-cn-CSDN博客1、修改device/rockchip/rk322xdiff--gita/device.mkb/device.mkindexec6bfaa..e7c32d1100755---a/device.mk+++b/device.mk@@-105,6+105,8@@en</div>
                    </li>
                    <li><a href="/article/1835374864970641408.htm"
                           title="kt文件和java文件_Java与Kotlin之间怎样进行互操作" target="_blank">kt文件和java文件_Java与Kotlin之间怎样进行互操作</a>
                        <span class="text-muted">铭空间</span>
<a class="tag" taget="_blank" href="/search/kt%E6%96%87%E4%BB%B6%E5%92%8Cjava%E6%96%87%E4%BB%B6/1.htm">kt文件和java文件</a>
                        <div>Java与Kotlin之间怎样进行互操作发布时间:2021-02-0210:50:43来源:亿速云阅读:98作者:小新这篇文章主要介绍了Java与Kotlin之间怎样进行互操作,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。前言目前kotlin是谷歌首推的开发Android的语言,但由于历史原因,我们绝大部分项目依旧还是以Java为主</div>
                    </li>
                    <li><a href="/article/1835369316342657024.htm"
                           title="Android shell 常用 debug 命令" target="_blank">Android shell 常用 debug 命令</a>
                        <span class="text-muted">晨春计</span>
<a class="tag" taget="_blank" href="/search/Audio/1.htm">Audio</a><a class="tag" taget="_blank" href="/search/debug/1.htm">debug</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                        <div>目录1、查看版本2、am命令3、pm命令4、dumpsys命令5、sed命令6、log定位查看APK进程号7、log定位使用场景1、查看版本1.1、Android串口终端执行getpropro.build.version.release#获取Android版本uname-a#查看linux内核版本信息uname-r#单独查看内核版本1.2、linux服务器执行lsb_release-a#查看Lin</div>
                    </li>
                    <li><a href="/article/1835332133149831168.htm"
                           title="2024年最全Flutter如何和Native通信-Android视角,Electron开发Android界面" target="_blank">2024年最全Flutter如何和Native通信-Android视角,Electron开发Android界面</a>
                        <span class="text-muted">2401_84544531</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/%E9%9D%A2%E8%AF%95/1.htm">面试</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a>
                        <div>总结【Android详细知识点思维脑图(技能树)】其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。虽然Android没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明Android中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪</div>
                    </li>
                    <li><a href="/article/1835288964056051712.htm"
                           title="分享一个基于python的电子书数据采集与可视化分析 hadoop电子书数据分析与推荐系统 spark大数据毕设项目(源码、调试、LW、开题、PPT)" target="_blank">分享一个基于python的电子书数据采集与可视化分析 hadoop电子书数据分析与推荐系统 spark大数据毕设项目(源码、调试、LW、开题、PPT)</a>
                        <span class="text-muted">计算机源码社</span>
<a class="tag" taget="_blank" href="/search/Python%E9%A1%B9%E7%9B%AE/1.htm">Python项目</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a><a class="tag" taget="_blank" href="/search/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E9%80%89%E9%A2%98/1.htm">计算机毕业设计选题</a><a class="tag" taget="_blank" href="/search/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E6%BA%90%E7%A0%81/1.htm">计算机毕业设计源码</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/spark%E6%AF%95%E8%AE%BE/1.htm">spark毕设</a>
                        <div>作者:计算机源码社个人简介:本人八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!学习资料、程序开发、技术解答、文档报告如需要源码,可以扫取文章下方二维码联系咨询Java项目微信小程序项目Android项目Python项目PHP项目ASP.NET项目Node.js项目选题推荐项目实战|p</div>
                    </li>
                    <li><a href="/article/1835230728099557376.htm"
                           title="android ndk 开发jni调用对象方法,数组参数" target="_blank">android ndk 开发jni调用对象方法,数组参数</a>
                        <span class="text-muted">wulongkou</span>
<a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E9%97%AE%E9%A2%98/1.htm">开发问题</a><a class="tag" taget="_blank" href="/search/%E5%AE%89%E5%8D%93%E7%9A%84%E4%BA%8B/1.htm">安卓的事</a><a class="tag" taget="_blank" href="/search/ndk/1.htm">ndk</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/studio/1.htm">studio</a><a class="tag" taget="_blank" href="/search/jni/1.htm">jni</a>
                        <div>一、JNI和NDK关系JNI是Java语言提供的Java和C/C++相互沟通的机制,Java可以通过JNI调用本地的C/C++代码,本地的C/C++的代码也可以调用java代码。JNI是本地编程接口,Java和C/C++互相通过的接口。Java通过C/C++使用本地的代码的一个关键性原因在于C/C++代码的高效性。NDK是一系列工具的集合。它提供了一系列的工具,帮助开发者快速开发C(或C++)的动</div>
                    </li>
                    <li><a href="/article/1835224173648113664.htm"
                           title="Android jni中数组参数的传递方式" target="_blank">Android jni中数组参数的传递方式</a>
                        <span class="text-muted">lokeyme</span>
<a class="tag" taget="_blank" href="/search/Andriod/1.htm">Andriod</a><a class="tag" taget="_blank" href="/search/android%E5%BC%80%E5%8F%91/1.htm">android开发</a><a class="tag" taget="_blank" href="/search/JNI/1.htm">JNI</a><a class="tag" taget="_blank" href="/search/NDK/1.htm">NDK</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/c%E8%AF%AD%E8%A8%80/1.htm">c语言</a>
                        <div>1、背景今天调试了一下Androidjni关于Java中调用C代码的程序,发现我的数组参数传递方式不对,导致值传递不正确,我的方法是:C代码,入口函数#include#includejintJava_sony_MedicalRecordDemo_MainActivity_decryptionSuccess(JNIEnv*env,jobjectthiz,jintAttr[]){returnAttr[</div>
                    </li>
                    <li><a href="/article/1835197073578881024.htm"
                           title="1-1.Jetpack 之 Navigation 简单编码模板" target="_blank">1-1.Jetpack 之 Navigation 简单编码模板</a>
                        <span class="text-muted">我命由我12345</span>
<a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/-/1.htm">-</a><a class="tag" taget="_blank" href="/search/Jetpack/1.htm">Jetpack</a><a class="tag" taget="_blank" href="/search/%E7%AE%80%E5%8C%96%E7%BC%96%E7%A8%8B/1.htm">简化编程</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/java-ee/1.htm">java-ee</a><a class="tag" taget="_blank" href="/search/android-studio/1.htm">android-studio</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/studio/1.htm">studio</a><a class="tag" taget="_blank" href="/search/%E5%AE%89%E5%8D%93/1.htm">安卓</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/jetpack/1.htm">jetpack</a>
                        <div>一、Navigation1、Navigation概述Navigation是Jetpack中的一个重要成员,它主要是结合导航图(NavigationGraph)来控制和简化Fragment之间的导航,即往哪里走,该怎么走2、Navigate引入在模块级build.gradle中引入相关依赖implementation'androidx.navigation:navigation-fragment:2</div>
                    </li>
                    <li><a href="/article/1835139546212298752.htm"
                           title="Android JetPack架构——结合记事本Demo一篇打通对Sqlite的增删改查结合常用jetpack架构应用" target="_blank">Android JetPack架构——结合记事本Demo一篇打通对Sqlite的增删改查结合常用jetpack架构应用</a>
                        <span class="text-muted">erhtre</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/jetpack/1.htm">jetpack</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a><a class="tag" taget="_blank" href="/search/sqlite/1.htm">sqlite</a>
                        <div>为什么要用Jetpack?========================================================================关于为什么要用Jetpack,我参考了许多的博客和官方文档,开阔了我对Android生态圈的理解和认识,在Jetpack推出前出现的许许多多强大的第三方框架与语言,典型代表无疑是强大的RxJava在Jetpack仍然有许多粉丝在一</div>
                    </li>
                    <li><a href="/article/1835139294000410624.htm"
                           title="Android干净架构MVI模板使用指南" target="_blank">Android干净架构MVI模板使用指南</a>
                        <span class="text-muted">井美婵Toby</span>

                        <div>Android干净架构MVI模板使用指南android-clean-architecture-mvi-boilerplateAforkofourcleanarchitectureboilerplateusingtheModel-View-Intentpattern项目地址:https://gitcode.com/gh_mirrors/an/android-clean-architecture-mv</div>
                    </li>
                    <li><a href="/article/1835136270758670336.htm"
                           title="⭐Unity 安卓环境中正确地读取和处理 XML 文件" target="_blank">⭐Unity 安卓环境中正确地读取和处理 XML 文件</a>
                        <span class="text-muted">惊鸿醉</span>
<a class="tag" taget="_blank" href="/search/Unity/1.htm">Unity</a><a class="tag" taget="_blank" href="/search/unity/1.htm">unity</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/xml/1.htm">xml</a>
                        <div>写了一个选择题Demo,电脑包和编辑器内无问题,但是打包安卓手机之后题目无法正常使用,想到的是安卓环境中正确地读取文件的问题改进方案:1.由于XmlDocument.Load方法在Android上的路径问题(由于文件位于APK内部,无法像在文件系统中那样直接访问),需要先使用UnityWebRequest来异步加载文件内容,然后再解析XML。2.异步处理:修改你的代码,以支持异步文件加载和处理,这</div>
                    </li>
                    <li><a href="/article/1835128195632951296.htm"
                           title="《Android进阶之光》读书笔记" target="_blank">《Android进阶之光》读书笔记</a>
                        <span class="text-muted">soleil雪寂</span>
<a class="tag" taget="_blank" href="/search/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/1.htm">读书笔记</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Android%E8%BF%9B%E9%98%B6%E4%B9%8B%E5%85%89/1.htm">Android进阶之光</a>
                        <div>文章目录第1章Android新特性1.1.Android5.0新特性1.2.RecyclerView1.1.4.3种Notification1.1.5.Toolbar与Palette1.1.6.Palette1.2.Android6.0新特性1.2.2.运行时权限机制1.3.Android7.0新特性第2章MaterialDesign2.2.DesignSupportLibrary常用控件详解第3</div>
                    </li>
                    <li><a href="/article/1835126172099375104.htm"
                           title="《Android进阶之光》— Android 书籍" target="_blank">《Android进阶之光》— Android 书籍</a>
                        <span class="text-muted">王睿丶</span>
<a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/%E6%B0%B8%E6%97%A0%E6%AD%A2%E5%A2%83/1.htm">永无止境</a><a class="tag" taget="_blank" href="/search/%E3%80%8AAndroid%E8%BF%9B%E9%98%B6%E4%B9%8B%E5%85%89%E3%80%8B/1.htm">《Android进阶之光》</a><a class="tag" taget="_blank" href="/search/Android%E4%B9%A6%E7%B1%8D/1.htm">Android书籍</a><a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/phoenix/1.htm">phoenix</a><a class="tag" taget="_blank" href="/search/%E7%A7%BB%E5%8A%A8%E5%BC%80%E5%8F%91/1.htm">移动开发</a>
                        <div>文章目录第1章Android新特性1第2章MaterialDesign48第3章View体系与自定义View87第4章多线程编程165第5章网络编程与网络框架204第6章设计模式271第7章事件总线308第8章函数响应式编程333第9章注解与依赖注入框架382第10章应用架构设计422第11章系统架构与MediaPlayer框架460出版年:2017-7简介:《Android进阶之光》是一本And</div>
                    </li>
                    <li><a href="/article/1835123902771195904.htm"
                           title="《android进阶之光》——多线程编程(上)" target="_blank">《android进阶之光》——多线程编程(上)</a>
                        <span class="text-muted">TAING要一直努力</span>
<a class="tag" taget="_blank" href="/search/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/1.htm">读书笔记</a>
                        <div>今天了解了下多线程编程,知识点如下:进程与线程:进程是什么?线程是什么?进程可以看作是程序的实体,是线程的容器,是受操作系统管理的基本运行单元,例如exe文件就是一个进程。线程是进程运行的一些子任务,是操作系统调度的最小单元,各线程拥有自己的计数器,堆栈,局部变量等,也可以访问线程间共享的内存。线程的状态有哪些?新创建,可运行,等待,超时等待,阻塞,终止怎么创建一个线程?-三种方法第一种,MyTr</div>
                    </li>
                    <li><a href="/article/1835118105613922304.htm"
                           title="android进阶之光!Android面试必备的集合源码详解,系列篇" target="_blank">android进阶之光!Android面试必备的集合源码详解,系列篇</a>
                        <span class="text-muted">程序员Sunbu</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a>
                        <div>前言面试:如果不准备充分的面试,完全是浪费时间,更是对自己的不负责。文末会给大家分享下我整理的Android面试专题及答案其中大部分都是大企业面试常问的面试题,可以对照这查漏补缺,当然了,这里所列的肯定不可能覆盖全部方式,不过对大家找工作肯定是有帮助!本月飞机到达上海,到今天第6天了,四家大公司华为,小米,映客,抖音,还有二家中小型公司。有几家已经面了几轮,下周还要面,挂了几家,不过目前已经选择了</div>
                    </li>
                    <li><a href="/article/1835094160550490112.htm"
                           title="Android-悬浮窗功能的实现(附Java、KT实现源码)(1)" target="_blank">Android-悬浮窗功能的实现(附Java、KT实现源码)(1)</a>
                        <span class="text-muted">egrhef</span>
<a class="tag" taget="_blank" href="/search/%E7%A8%8B%E5%BA%8F%E5%91%98/1.htm">程序员</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>//获取服务的操作对象valbinder=serviceasFloatWinfowServices.MyBinderbinder.service}overridefunonServiceDisconnected(name:ComponentName){}}overridefunonActivityResult(requestCode:Int,resultCode:Int,data:Intent){</div>
                    </li>
                    <li><a href="/article/1835061636268912640.htm"
                           title="Visual Studio中的Android模拟器使用详解" target="_blank">Visual Studio中的Android模拟器使用详解</a>
                        <span class="text-muted">wurui8</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/studio/1.htm">studio</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/android%E5%BA%94%E7%94%A8/1.htm">android应用</a>
                        <div>关注微信号:javalearns随时随地学Java或扫一扫随时随地学JavaMicrosoft本周发布了VisualStudio2015预览版,里面包含Android开发工具.安装的时候,如果选Android开发,VisualStudio会把调试Android应用程序用的VisualStudio模拟器也装上.在介绍这个新模拟器之前,我们先来聊一聊,为什么需要一个新的Android模拟器–当然,你也</div>
                    </li>
                    <li><a href="/article/1835057219947819008.htm"
                           title="Unity 热更 之 【HybirdCLR】+【YooAsset】 [安卓 Android端] [代码 + 资源热更] 功能的 简单实现演示" target="_blank">Unity 热更 之 【HybirdCLR】+【YooAsset】 [安卓 Android端] [代码 + 资源热更] 功能的 简单实现演示</a>
                        <span class="text-muted">仙魁XAN</span>
<a class="tag" taget="_blank" href="/search/Unity/1.htm">Unity</a><a class="tag" taget="_blank" href="/search/%E8%BF%9B%E9%98%B6/1.htm">进阶</a><a class="tag" taget="_blank" href="/search/unity/1.htm">unity</a><a class="tag" taget="_blank" href="/search/HybirdCLR/1.htm">HybirdCLR</a><a class="tag" taget="_blank" href="/search/YooAsset/1.htm">YooAsset</a><a class="tag" taget="_blank" href="/search/HotUpdate/1.htm">HotUpdate</a><a class="tag" taget="_blank" href="/search/%E7%83%AD%E6%9B%B4%E6%96%B0/1.htm">热更新</a>
                        <div>Unity热更之【HybirdCLR】+【YooAsset】[安卓Android端][代码+资源热更]功能的简单实现演示目录Unity热更之【HybirdCLR】+【YooAsset】[安卓Android端][代码+资源热更]功能的简单实现演示一、简单介绍二、HybridCLR三、YooAsset四、HybirdCLR引入工程五、YooAsset引入工程六、Python服务器简单构建七、Hybir</div>
                    </li>
                    <li><a href="/article/1835053685592387584.htm"
                           title="Android 用线程池实现一个简单的任务队列(Kotlin)" target="_blank">Android 用线程池实现一个简单的任务队列(Kotlin)</a>
                        <span class="text-muted">深海呐</span>
<a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Android%E8%BF%9B%E9%98%B6/1.htm">Android进阶</a><a class="tag" taget="_blank" href="/search/%23/1.htm">#</a><a class="tag" taget="_blank" href="/search/Kotlin/1.htm">Kotlin</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/kotlin/1.htm">kotlin</a><a class="tag" taget="_blank" href="/search/%E7%BA%BF%E7%A8%8B%E6%B1%A0/1.htm">线程池</a><a class="tag" taget="_blank" href="/search/%E5%BB%B6%E6%97%B6%E4%BB%BB%E5%8A%A1%E9%98%9F%E5%88%97/1.htm">延时任务队列</a><a class="tag" taget="_blank" href="/search/%E7%BA%BF%E7%A8%8B%E6%B1%A0%E5%BB%B6%E6%97%B6%E4%BB%BB%E5%8A%A1/1.htm">线程池延时任务</a>
                        <div>关于线程池,Kotlin和java的使用方式一样在Android中,很多人喜欢用Handler的postDelayed()去实现延时任务.要使用postDelayed(),去实现延时任务队列,就不可避免要使用递归.但是这样做,代码的简洁性,和书写的简易,就远不如使用线程池.使用线程池的简单程度:privatevalmThreadPool=Executors.newSingleThreadSched</div>
                    </li>
                    <li><a href="/article/1835053432449363968.htm"
                           title="(小白入门)Windows环境下搭建React Native Android开发环境" target="_blank">(小白入门)Windows环境下搭建React Native Android开发环境</a>
                        <span class="text-muted">码农老黑</span>
<a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/React/1.htm">React</a><a class="tag" taget="_blank" href="/search/Native/1.htm">Native</a><a class="tag" taget="_blank" href="/search/%E7%A7%BB%E5%8A%A8%E5%BC%80%E5%8F%91/1.htm">移动开发</a><a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/studio/1.htm">studio</a>
                        <div>ReactNative(简称RN)是Facebook于2015年4月开源的跨平台移动应用开发框架,是Facebook早先开源的UI框架React在原生移动应用平台的衍生产物,目前支持iOS和Android两大平台。RN的环境搭建在RN的中文社区有所介绍,但是对于小白来说还是有些太过简略了。RN中文社区详见参考,本文不涉及的问题也许在其中能够有所解答。ReactNative思想底层引擎是JavaSc</div>
                    </li>
                    <li><a href="/article/1835051666974535680.htm"
                           title="Android Dialog圆角设置无效的问题" target="_blank">Android Dialog圆角设置无效的问题</a>
                        <span class="text-muted">ly969434341</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                        <div>一,参考AndroidDialog圆角设置无效的问题https://blog.csdn.net/woshi_awei/article/details/99664527Android自定义Dialog实现通用圆角对话框https://cloud.tencent.com/developer/article/1740956二,原因Diallog的默认背景是白色(直角背景),我自定义的Dialog背景也是</div>
                    </li>
                    <li><a href="/article/1835050659297193984.htm"
                           title="MultiSnapRecyclerView:让Android RecyclerView的滚动停靠更灵活" target="_blank">MultiSnapRecyclerView:让Android RecyclerView的滚动停靠更灵活</a>
                        <span class="text-muted">技术无疆</span>
<a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/ui/1.htm">ui</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/studio/1.htm">studio</a><a class="tag" taget="_blank" href="/search/android-studio/1.htm">android-studio</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/androidx/1.htm">androidx</a>
                        <div>在Android应用开发中,RecyclerView是一个强大且灵活的组件,用于展示大量数据集合。然而,标准的RecyclerView只支持单一的滚动停靠点,这在某些场景下可能不够灵活。为了解决这个问题,TakuSemba开发了一个名为MultiSnapRecyclerView的库,它允许开发者在RecyclerView中实现多个滚动停靠点。文章目录什么是MultiSnapRecyclerView</div>
                    </li>
                    <li><a href="/article/1835050154282020864.htm"
                           title="Android界面特效全汇总" target="_blank">Android界面特效全汇总</a>
                        <span class="text-muted">小飞鹤</span>
<a class="tag" taget="_blank" href="/search/Android%E5%BC%80%E5%8F%91%E8%AF%A6%E8%A7%A3/1.htm">Android开发详解</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                        <div>(一)Activity页面切换的效果Android2.0之后有了overridePendingTransition(),其中里面两个参数,一个是前一个activity的退出两一个activity的进入,Java代码1.@OverridepublicvoidonCreate(BundlesavedInstanceState){2.super.onCreate(savedInstanceState);</div>
                    </li>
                                <li><a href="/article/111.htm"
                                       title="JAVA基础" target="_blank">JAVA基础</a>
                                    <span class="text-muted">灵静志远</span>
<a class="tag" taget="_blank" href="/search/%E4%BD%8D%E8%BF%90%E7%AE%97/1.htm">位运算</a><a class="tag" taget="_blank" href="/search/%E5%8A%A0%E8%BD%BD/1.htm">加载</a><a class="tag" taget="_blank" href="/search/Date/1.htm">Date</a><a class="tag" taget="_blank" href="/search/%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%B1%A0/1.htm">字符串池</a><a class="tag" taget="_blank" href="/search/%E8%A6%86%E7%9B%96/1.htm">覆盖</a>
                                    <div>一、类的初始化顺序 
1 (静态变量,静态代码块)-->(变量,初始化块)--> 构造器 
 同一括号里的,根据它们在程序中的顺序来决定。上面所述是同一类中。如果是继承的情况,那就在父类到子类交替初始化。 
 
二、String 
1 String a = "abc"; 
 JAVA虚拟机首先在字符串池中查找是否已经存在了值为"abc"的对象,根</div>
                                </li>
                                <li><a href="/article/238.htm"
                                       title="keepalived实现redis主从高可用" target="_blank">keepalived实现redis主从高可用</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/redis/1.htm">redis</a>
                                    <div>方案说明 
 
两台机器(称为A和B),以统一的VIP对外提供服务 
1.正常情况下,A和B都启动,B会把A的数据同步过来(B is slave of A) 
2.当A挂了后,VIP漂移到B;B的keepalived 通知redis 执行:slaveof no one,由B提供服务 
3.当A起来后,VIP不切换,仍在B上面;而A的keepalived 通知redis 执行slaveof B,开始</div>
                                </li>
                                <li><a href="/article/365.htm"
                                       title="java文件操作大全" target="_blank">java文件操作大全</a>
                                    <span class="text-muted">0624chenhong</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                                    <div>最近在博客园看到一篇比较全面的文件操作文章,转过来留着。 
 
http://www.cnblogs.com/zhuocheng/archive/2011/12/12/2285290.html 
 
转自http://blog.sina.com.cn/s/blog_4a9f789a0100ik3p.html 
 
 
一.获得控制台用户输入的信息 
 
   &nbs</div>
                                </li>
                                <li><a href="/article/492.htm"
                                       title="android学习任务" target="_blank">android学习任务</a>
                                    <span class="text-muted">不懂事的小屁孩</span>
<a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C/1.htm">工作</a>
                                    <div>任务 
完成情况   搞清楚带箭头的pupupwindows和不带的使用 已完成   熟练使用pupupwindows和alertdialog,并搞清楚两者的区别 已完成   熟练使用android的线程handler,并敲示例代码 进行中   了解游戏2048的流程,并完成其代码工作 进行中-差几个actionbar   研究一下android的动画效果,写一个实例 已完成   复习fragem</div>
                                </li>
                                <li><a href="/article/619.htm"
                                       title="zoom.js" target="_blank">zoom.js</a>
                                    <span class="text-muted">换个号韩国红果果</span>
<a class="tag" taget="_blank" href="/search/oom/1.htm">oom</a>
                                    <div>它的基于bootstrap 的 
https://raw.github.com/twbs/bootstrap/master/js/transition.js  transition.js模块引用顺序 
 

<link rel="stylesheet" href="style/zoom.css">
<script src=&q</div>
                                </li>
                                <li><a href="/article/746.htm"
                                       title="详解Oracle云操作系统Solaris 11.2" target="_blank">详解Oracle云操作系统Solaris 11.2</a>
                                    <span class="text-muted">蓝儿唯美</span>
<a class="tag" taget="_blank" href="/search/Solaris/1.htm">Solaris</a>
                                    <div>当Oracle发布Solaris 11时,它将自己的操作系统称为第一个面向云的操作系统。Oracle在发布Solaris 11.2时继续它以云为中心的基调。但是,这些说法没有告诉我们为什么Solaris是配得上云的。幸好,我们不需要等太久。Solaris11.2有4个重要的技术可以在一个有效的云实现中发挥重要作用:OpenStack、内核域、统一存档(UA)和弹性虚拟交换(EVS)。  </div>
                                </li>
                                <li><a href="/article/873.htm"
                                       title="spring学习——springmvc(一)" target="_blank">spring学习——springmvc(一)</a>
                                    <span class="text-muted">a-john</span>
<a class="tag" taget="_blank" href="/search/springMVC/1.htm">springMVC</a>
                                    <div>Spring MVC基于模型-视图-控制器(Model-View-Controller,MVC)实现,能够帮助我们构建像Spring框架那样灵活和松耦合的Web应用程序。 
  
1,跟踪Spring MVC的请求 
请求的第一站是Spring的DispatcherServlet。与大多数基于Java的Web框架一样,Spring MVC所有的请求都会通过一个前端控制器Servlet。前</div>
                                </li>
                                <li><a href="/article/1000.htm"
                                       title="hdu4342 History repeat itself-------多校联合五" target="_blank">hdu4342 History repeat itself-------多校联合五</a>
                                    <span class="text-muted">aijuans</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E8%AE%BA/1.htm">数论</a>
                                    <div>水题就不多说什么了。 
#include<iostream>#include<cstdlib>#include<stdio.h>#define ll __int64using namespace std;int main(){    int t;    ll n;    scanf("%d",&t);    while(t--)   </div>
                                </li>
                                <li><a href="/article/1127.htm"
                                       title="EJB和javabean的区别" target="_blank">EJB和javabean的区别</a>
                                    <span class="text-muted">asia007</span>
<a class="tag" taget="_blank" href="/search/bean/1.htm">bean</a><a class="tag" taget="_blank" href="/search/ejb/1.htm">ejb</a>
                                    <div>EJB不是一般的JavaBean,EJB是企业级JavaBean,EJB一共分为3种,实体Bean,消息Bean,会话Bean,书写EJB是需要遵循一定的规范的,具体规范你可以参考相关的资料.另外,要运行EJB,你需要相应的EJB容器,比如Weblogic,Jboss等,而JavaBean不需要,只需要安装Tomcat就可以了 
  
1.EJB用于服务端应用开发, 而JavaBeans</div>
                                </li>
                                <li><a href="/article/1254.htm"
                                       title="Struts的action和Result总结" target="_blank">Struts的action和Result总结</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/struts/1.htm">struts</a><a class="tag" taget="_blank" href="/search/Action%E9%85%8D%E7%BD%AE/1.htm">Action配置</a><a class="tag" taget="_blank" href="/search/Result%E9%85%8D%E7%BD%AE/1.htm">Result配置</a>
                                    <div>  
  
一:Action的配置详解: 
     下面是一个Struts中一个空的Struts.xml的配置文件 
    
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
	&quo</div>
                                </li>
                                <li><a href="/article/1381.htm"
                                       title="如何带好自已的团队" target="_blank">如何带好自已的团队</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86/1.htm">项目管理</a><a class="tag" taget="_blank" href="/search/%E5%9B%A2%E9%98%9F%E7%AE%A1%E7%90%86/1.htm">团队管理</a><a class="tag" taget="_blank" href="/search/%E5%9B%A2%E9%98%9F/1.htm">团队</a>
                                    <div>在网上看到博客" 
怎么才能让团队成员好好干活"的评论,觉得写的比较好。   原文如下:   我做团队管理有几年了吧,我和你分享一下我认为带好团队的几点: 
1.诚信 
        对团队内成员,无论是技术研究、交流、问题探讨,要尽可能的保持一种诚信的态度,用心去做好,你的团队会感觉得到。   2.努力提</div>
                                </li>
                                <li><a href="/article/1508.htm"
                                       title="Java代码混淆工具" target="_blank">Java代码混淆工具</a>
                                    <span class="text-muted">sunjing</span>
<a class="tag" taget="_blank" href="/search/ProGuard/1.htm">ProGuard</a>
                                    <div>Open Source Obfuscators 
ProGuard 
http://java-source.net/open-source/obfuscators/proguardProGuard is a free Java class file shrinker and obfuscator. It can detect and remove unused classes, fields, m</div>
                                </li>
                                <li><a href="/article/1635.htm"
                                       title="【Redis三】基于Redis sentinel的自动failover主从复制" target="_blank">【Redis三】基于Redis sentinel的自动failover主从复制</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/redis/1.htm">redis</a>
                                    <div>在第二篇中使用2.8.17搭建了主从复制,但是它存在Master单点问题,为了解决这个问题,Redis从2.6开始引入sentinel,用于监控和管理Redis的主从复制环境,进行自动failover,即Master挂了后,sentinel自动从从服务器选出一个Master使主从复制集群仍然可以工作,如果Master醒来再次加入集群,只能以从服务器的形式工作。 
  什么是Sentine</div>
                                </li>
                                <li><a href="/article/1762.htm"
                                       title="使用代理实现Hibernate Dao层自动事务" target="_blank">使用代理实现Hibernate Dao层自动事务</a>
                                    <span class="text-muted">白糖_</span>
<a class="tag" taget="_blank" href="/search/DAO/1.htm">DAO</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a><a class="tag" taget="_blank" href="/search/%E6%A1%86%E6%9E%B6/1.htm">框架</a><a class="tag" taget="_blank" href="/search/Hibernate/1.htm">Hibernate</a>
                                    <div>都说spring利用AOP实现自动事务处理机制非常好,但在只有hibernate这个框架情况下,我们开启session、管理事务就往往很麻烦。 
public void save(Object obj){
		Session session = this.getSession();
		Transaction tran = session.beginTransaction();
		try </div>
                                </li>
                                <li><a href="/article/1889.htm"
                                       title="maven3实战读书笔记" target="_blank">maven3实战读书笔记</a>
                                    <span class="text-muted">braveCS</span>
<a class="tag" taget="_blank" href="/search/maven3/1.htm">maven3</a>
                                    <div>Maven简介 
是什么? 
Is a software project management and comprehension tool.项目管理工具 
是基于POM概念(工程对象模型) 
[设计重复、编码重复、文档重复、构建重复,maven最大化消除了构建的重复] 
[与XP:简单、交流与反馈;测试驱动开发、十分钟构建、持续集成、富有信息的工作区] 
  
  
功能: </div>
                                </li>
                                <li><a href="/article/2016.htm"
                                       title="编程之美-子数组的最大乘积" target="_blank">编程之美-子数组的最大乘积</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/%E7%BC%96%E7%A8%8B%E4%B9%8B%E7%BE%8E/1.htm">编程之美</a>
                                    <div>

public class MaxProduct {

	/**
	 * 编程之美 子数组的最大乘积
	 * 题目: 给定一个长度为N的整数数组,只允许使用乘法,不能用除法,计算任意N-1个数的组合中乘积中最大的一组,并写出算法的时间复杂度。
	 * 以下程序对应书上两种方法,求得“乘积中最大的一组”的乘积——都是有溢出的可能的。
	 * 但按题目的意思,是要求得这个子数组,而不</div>
                                </li>
                                <li><a href="/article/2143.htm"
                                       title="读书笔记-2" target="_blank">读书笔记-2</a>
                                    <span class="text-muted">chengxuyuancsdn</span>
<a class="tag" taget="_blank" href="/search/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/1.htm">读书笔记</a>
                                    <div>1、反射 
2、oracle年-月-日 时-分-秒 
3、oracle创建有参、无参函数 
4、oracle行转列 
5、Struts2拦截器 
6、Filter过滤器(web.xml) 
 
 
1、反射
(1)检查类的结构
在java.lang.reflect包里有3个类Field,Method,Constructor分别用于描述类的域、方法和构造器。
2、oracle年月日时分秒
s</div>
                                </li>
                                <li><a href="/article/2270.htm"
                                       title="[求学与房地产]慎重选择IT培训学校" target="_blank">[求学与房地产]慎重选择IT培训学校</a>
                                    <span class="text-muted">comsci</span>
<a class="tag" taget="_blank" href="/search/it/1.htm">it</a>
                                    <div>      关于培训学校的教学和教师的问题,我们就不讨论了,我主要关心的是这个问题 
 
      培训学校的教学楼和宿舍的环境和稳定性问题 
 
      我们大家都知道,房子是一个比较昂贵的东西,特别是那种能够当教室的房子... 
 
&nb</div>
                                </li>
                                <li><a href="/article/2397.htm"
                                       title="RMAN配置中通道(CHANNEL)相关参数 PARALLELISM 、FILESPERSET的关系" target="_blank">RMAN配置中通道(CHANNEL)相关参数 PARALLELISM 、FILESPERSET的关系</a>
                                    <span class="text-muted">daizj</span>
<a class="tag" taget="_blank" href="/search/oracle/1.htm">oracle</a><a class="tag" taget="_blank" href="/search/rman/1.htm">rman</a><a class="tag" taget="_blank" href="/search/filesperset/1.htm">filesperset</a><a class="tag" taget="_blank" href="/search/PARALLELISM/1.htm">PARALLELISM</a>
                                    <div>RMAN配置中通道(CHANNEL)相关参数 PARALLELISM 、FILESPERSET的关系 转 
 
PARALLELISM --- 
 
我们还可以通过parallelism参数来指定同时"自动"创建多少个通道: 
RMAN > configure device type disk parallelism 3 ; 
表示启动三个通道,可以加快备份恢复的速度。 </div>
                                </li>
                                <li><a href="/article/2524.htm"
                                       title="简单排序:冒泡排序" target="_blank">简单排序:冒泡排序</a>
                                    <span class="text-muted">dieslrae</span>
<a class="tag" taget="_blank" href="/search/%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F/1.htm">冒泡排序</a>
                                    <div>
    public void bubbleSort(int[] array){
        for(int i=1;i<array.length;i++){
            for(int k=0;k<array.length-i;k++){
                if(array[k] > array[k+1]){
             </div>
                                </li>
                                <li><a href="/article/2651.htm"
                                       title="初二上学期难记单词三" target="_blank">初二上学期难记单词三</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/sciet/1.htm">sciet</a>
                                    <div>concert 音乐会 
tonight 今晚 
famous 有名的;著名的 
song 歌曲 
thousand 千 
accident 事故;灾难 
careless 粗心的,大意的 
break 折断;断裂;破碎 
heart 心(脏) 
happen  偶尔发生,碰巧 
tourist 旅游者;观光者 
science (自然)科学 
marry 结婚 
subject 题目;</div>
                                </li>
                                <li><a href="/article/2778.htm"
                                       title="I.安装Memcahce 1. 安装依赖包libevent Memcache需要安装libevent,所以安装前可能需要执行 Shell代码 收藏代码" target="_blank">I.安装Memcahce 1. 安装依赖包libevent Memcache需要安装libevent,所以安装前可能需要执行 Shell代码 收藏代码</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/redis/1.htm">redis</a>
                                    <div>wget http://download.redis.io/redis-stable.tar.gz 
tar xvzf redis-stable.tar.gz 
cd redis-stable 
make 
  
前面3步应该没有问题,主要的问题是执行make的时候,出现了异常。 
异常一: 
make[2]: cc: Command not found 
异常原因:没有安装g</div>
                                </li>
                                <li><a href="/article/2905.htm"
                                       title="并发容器" target="_blank">并发容器</a>
                                    <span class="text-muted">shuizhaosi888</span>
<a class="tag" taget="_blank" href="/search/%E5%B9%B6%E5%8F%91%E5%AE%B9%E5%99%A8/1.htm">并发容器</a>
                                    <div>   通过并发容器来改善同步容器的性能,同步容器将所有对容器状态的访问都串行化,来实现线程安全,这种方式严重降低并发性,当多个线程访问时,吞吐量严重降低。 
   并发容器ConcurrentHashMap 
      替代同步基于散列的Map,通过Lock控制。 
  &nb</div>
                                </li>
                                <li><a href="/article/3032.htm"
                                       title="Spring Security(12)——Remember-Me功能" target="_blank">Spring Security(12)——Remember-Me功能</a>
                                    <span class="text-muted">234390216</span>
<a class="tag" taget="_blank" href="/search/Spring+Security/1.htm">Spring Security</a><a class="tag" taget="_blank" href="/search/Remember+Me/1.htm">Remember Me</a><a class="tag" taget="_blank" href="/search/%E8%AE%B0%E4%BD%8F%E6%88%91/1.htm">记住我</a>
                                    <div>Remember-Me功能 
  
目录 
  
1.1     概述 
1.2     基于简单加密token的方法 
1.3     基于持久化token的方法 
1.4     Remember-Me相关接口和实现</div>
                                </li>
                                <li><a href="/article/3159.htm"
                                       title="位运算" target="_blank">位运算</a>
                                    <span class="text-muted">焦志广</span>
<a class="tag" taget="_blank" href="/search/%E4%BD%8D%E8%BF%90%E7%AE%97/1.htm">位运算</a>
                                    <div>
一、位运算符C语言提供了六种位运算符: 
 
& 按位与 
| 按位或 
^ 按位异或 
~ 取反 
<< 左移 
>> 右移 
 
 

1. 按位与运算 按位与运算符"&"是双目运算符。其功能是参与运算的两数各对应的二进位相与。只有对应的两个二进位均为1时,结果位才为1 ,否则为0。参与运算的数以补码方式出现。 
 
例如:9&am</div>
                                </li>
                                <li><a href="/article/3286.htm"
                                       title="nodejs 数据库连接 mongodb mysql" target="_blank">nodejs 数据库连接 mongodb mysql</a>
                                    <span class="text-muted">liguangsong</span>
<a class="tag" taget="_blank" href="/search/mongodb/1.htm">mongodb</a><a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/node/1.htm">node</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93%E8%BF%9E%E6%8E%A5/1.htm">数据库连接</a>
                                    <div>1.mysql 连接 
   package.json中dependencies加入 
  
  
"mysql":"~2.7.0" 
   执行 npm install 
  
   在config 下创建文件 database.js 
    
</div>
                                </li>
                                <li><a href="/article/3413.htm"
                                       title="java动态编译" target="_blank">java动态编译</a>
                                    <span class="text-muted">olive6615</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/HotSpot/1.htm">HotSpot</a><a class="tag" taget="_blank" href="/search/jvm/1.htm">jvm</a><a class="tag" taget="_blank" href="/search/%E5%8A%A8%E6%80%81%E7%BC%96%E8%AF%91/1.htm">动态编译</a>
                                    <div>    在HotSpot虚拟机中,有两个技术是至关重要的,即动态编译(Dynamic compilation)和Profiling。 
    HotSpot是如何动态编译Javad的bytecode呢?Java bytecode是以解释方式被load到虚拟机的。HotSpot里有一个运行监视器,即Profile Monitor,专门监视</div>
                                </li>
                                <li><a href="/article/3540.htm"
                                       title="Storm0.9.5的集群部署配置优化" target="_blank">Storm0.9.5的集群部署配置优化</a>
                                    <span class="text-muted">roadrunners</span>
<a class="tag" taget="_blank" href="/search/%E4%BC%98%E5%8C%96/1.htm">优化</a><a class="tag" taget="_blank" href="/search/storm.yaml/1.htm">storm.yaml</a>
                                    <div>nimbus结点配置(storm.yaml)信息: 
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional inf</div>
                                </li>
                                <li><a href="/article/3667.htm"
                                       title="101个MySQL 的调节和优化的提示" target="_blank">101个MySQL 的调节和优化的提示</a>
                                    <span class="text-muted">tomcat_oracle</span>
<a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a>
                                    <div> 1. 拥有足够的物理内存来把整个InnoDB文件加载到内存中——在内存中访问文件时的速度要比在硬盘中访问时快的多。     2. 不惜一切代价避免使用Swap交换分区 – 交换时是从硬盘读取的,它的速度很慢。     3. 使用电池供电的RAM(注:RAM即随机存储器)。     4. 使用高级的RAID(注:Redundant Arrays of Inexpensive Disks,即磁盘阵列</div>
                                </li>
                                <li><a href="/article/3794.htm"
                                       title="zoj 3829 Known Notation(贪心)" target="_blank">zoj 3829 Known Notation(贪心)</a>
                                    <span class="text-muted">阿尔萨斯</span>
<a class="tag" taget="_blank" href="/search/ZOJ/1.htm">ZOJ</a>
                                    <div> 题目链接:zoj 3829 Known Notation 
 题目大意:给定一个不完整的后缀表达式,要求有2种不同操作,用尽量少的操作使得表达式完整。 
 解题思路:贪心,数字的个数要要保证比∗的个数多1,不够的话优先补在开头是最优的。然后遍历一遍字符串,碰到数字+1,碰到∗-1,保证数字的个数大于等1,如果不够减的话,可以和最后面的一个数字交换位置(用栈维护十分方便),因为添加和交换代价都是1</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>