在Android中创建实时新闻APP | 在5个简单步骤中

In this article, we are going to create a simple News App in Android. Users would be able to read live news articles from different news sources in this APP. You should have basic knowledge of Java, OPPs, Activity, Fragment, anyone networking library, Layouts, and Recycler view in order to grasp this article.

在本文中,我们将在Android中创建一个简单的News App 。 用户将能够在此APP中阅读来自不同新闻来源的实时新闻报道。 您应该具有Java,OPP,Activity,Fragment,任何网络库LayoutsRecycler视图的基础知识,才能掌握本文。

We are going to follow these 5 steps to create this App.

我们将按照以下5个步骤创建此应用。

  1. Collect news APIs.

    收集新闻API

  2. Create the main Activity.

    创建主活动

  3. Create Fragments with the Tab for different news sources

    使用标签为不同的新闻来源创建片段

  4. Create a Recycler View for each Fragment to display a list of the news articles.

    为每个片段创建一个“ 回收者视图 ”以显示新闻列表。

  5. When a user clicks on a news article, redirect to the next Activity.

    当用户单击新闻文章时,重定向到下一个活动

You can have a look at the following video to know what we are going to create by the end of this blog.

您可以看以下视频,以了解我们在本博客末尾将要创建的内容。

News App
新闻应用

Except for the first step rest of the four steps are divided into Java classes. We will discuss each step one by one.

除第一步外,其余四个步骤均分为Java类。 我们将一步一步地讨论每个步骤。

Let’s discuss each step in detail now.

现在让我们详细讨论每个步骤。

1.收集新闻API (1. Collecting News APIs)

Our first step is to collect news data through News APIs. As you have seen in the video I am displaying news title, author name, publish date, an image of the article, and a button (that will redirect you in the next activity) in form of recycler view (repeatable) with each fragment.

我们的第一步是通过新闻API收集新闻数据。 正如您在视频中看到的那样,我以每个片段的回收者视图(可重复)的形式显示新闻标题作者姓名发布日期 ,文章图片按钮 (将在下一个活动中重定向您)。

For this, we have to collect the data from the News API. And we will display this data on the UI. As you have seen above video, we are displaying the 10 news articles in 10 Tabs (each tab for one news source). For this, you have to set the API according to news sources. First, read this news API documentation and generate your API key.

为此,我们必须从News API收集数据。 我们将在UI上显示此数据。 正如您在视频中看到的那样,我们在10个选项卡(一个新闻源的每个选项卡)中显示10条新闻文章。 为此,您必须根据新闻来源设置API。 首先,请阅读此新闻API文档并生成您的API密钥

I am using the below API. And you can use the below API according to your preferred news sources. You will get the list of news sources from this API.

我正在使用以下API。 您可以根据自己的喜好使用以下API 资料来源 您将从此

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值