PopNewsApp

所属分类:编程语言基础
开发工具:Java
文件大小:1385KB
下载次数:0
上传日期:2020-06-28 12:16:16
上 传 者sh-1993
说明:  具有简单用户界面的新闻应用程序。
(News App with a simple user interface.)

文件列表:
.idea (0, 2020-06-28)
.idea\.name (8, 2020-06-28)
.idea\codeStyles (0, 2020-06-28)
.idea\codeStyles\Project.xml (3309, 2020-06-28)
.idea\gradle.xml (886, 2020-06-28)
.idea\jarRepositories.xml (1052, 2020-06-28)
.idea\misc.xml (357, 2020-06-28)
.idea\runConfigurations.xml (564, 2020-06-28)
.idea\vcs.xml (180, 2020-06-28)
Screenshot (0, 2020-06-28)
Screenshot\Screenshot_2020-06-28-15-58-49-559_com.rajkamani.popnews.jpg (783319, 2020-06-28)
Screenshot\Screenshot_2020-06-28-15-59-06-098_com.rajkamani.popnews.jpg (565206, 2020-06-28)
app (0, 2020-06-28)
app\build.gradle (1469, 2020-06-28)
app\proguard-rules.pro (750, 2020-06-28)
app\src (0, 2020-06-28)
app\src\androidTest (0, 2020-06-28)
app\src\androidTest\java (0, 2020-06-28)
app\src\androidTest\java\com (0, 2020-06-28)
app\src\androidTest\java\com\rajkamani (0, 2020-06-28)
app\src\androidTest\java\com\rajkamani\popnews (0, 2020-06-28)
app\src\androidTest\java\com\rajkamani\popnews\ExampleInstrumentedTest.java (756, 2020-06-28)
app\src\main (0, 2020-06-28)
app\src\main\AndroidManifest.xml (1605, 2020-06-28)
app\src\main\ic_launcher-playstore.png (24535, 2020-06-28)
app\src\main\java (0, 2020-06-28)
app\src\main\java\com (0, 2020-06-28)
app\src\main\java\com\rajkamani (0, 2020-06-28)
app\src\main\java\com\rajkamani\popnews (0, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\AboutArticleDetail.java (1811, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\AboutUs.java (1298, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\MainActivity.java (1076, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\OnOptionMenuCreated.java (1107, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\SplashScreen.java (1135, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\VolleySingleton (0, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\VolleySingleton\VolleySingleton.java (976, 2020-06-28)
app\src\main\java\com\rajkamani\popnews\adapter (0, 2020-06-28)
... ...

# PopNewsApp Hello friends,
I have created a very Basic News App. which fetch data from API.

Screenshot

ss1/ss2/ further details as follow :

API Used

https://newsapi.org/

If You want to create your app like i have created then you must find news API from above link and generate a Key.
After Getting your key You must have to place key in Constants.java file.

static final String BaseUrl ="https://newsapi.org/v2/top-headlines?country=in&apiKey="; static final String API_KEY="Your Api key goes here";

Network Library Used

Volley Library here: https://developer.android.com/training/volley
In this project there is one file where volley Library is used.
file Path : PopNewsApp/app/src/main/java/com/rajkamani/popnews/apicall/ApiCall.java JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener() { @Override public void onResponse(JSONObject response) { try { JSONArray jsonArray = response.getJSONArray("articles"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject ArticleNews = jsonArray.getJSONObject(i); Article article = new Article(); String author = ArticleNews.getString("author"); String title = ArticleNews.getString("title"); String des = ArticleNews.getString("description"); String articleUrl = ArticleNews.getString("url"); String imageUrl = ArticleNews.getString("urlToImage"); String time = ArticleNews.getString("publishedAt"); Source source = new Source(); JSONObject jsonObjectSource = ArticleNews.getJSONObject("source"); String publishername = jsonObjectSource.getString("name"); article.setAuthor(author); article.setTitle(title); article.setDescription(des); article.setUrlToArticle(articleUrl); article.setUrlToImage(imageUrl); article.setPublishedAt(time); articlesList.add(article); source.setName(publishername); sourcesList.add(source); RecycleAdapter recycleAdapter = new RecycleAdapter(context, articlesList, sourcesList); recyclerView.setAdapter(recycleAdapter); spinKitView.setVisibility(View.INVISIBLE); } } catch (JSONException e) { e.printStackTrace(); Toast.makeText(context, "Error In respons", Toast.LENGTH_SHORT).show(); } }

Other Details

For display news I have Used Cardview With RecyclerView and you can find recyclerview Adapter here : RecycleAdapter.java file under Adapter folder.

For display multiple category i have used TabLayout and fragments You can find all 7 Fragments in Fragment folder.
And Adapter for fragments with tablayout in Adapter Folder PagerAdapter.java


近期下载者

相关文件


收藏者