Share a very good news client (based on Baidu data)

Share a very good news client (based on Baidu data)

Source code introduction: Based on Baidu data, a very useful news client.

Source code effect:

Source code snippet:

  1. package com.linpeng.baidunewssearch;
  2.   
  3. import java.lang.reflect.Method;
  4.   
  5. import com.linpeng.baidunewssearch.R;
  6. import com.linpeng.fragment.FragmentNews;
  7. import com.linpeng.fragment.FragmentPhoto;
  8. import com.linpeng.fragment.FragmentPostbar;
  9. import com.linpeng.fragment.FragmentQuestion;
  10.   
  11. import android.view.Menu;
  12. import android.view.MenuItem;
  13. import android.view.View;
  14. import android.view.Window;
  15. import android.app.Activity;
  16. import android.app.Fragment;
  17. import android.content.Intent;
  18. import android.os.Bundle;
  19.    
  20.   
  21. public   class MainActivity extends Activity {
  22.   
  23. private Fragment[] fragments = new Fragment[ 4 ];
  24.   
  25. @Override  
  26. protected   void onCreate(Bundle savedInstanceState) {
  27. super .onCreate(savedInstanceState);
  28. setContentView(R.layout.activity_main);
  29.    
  30. fragments[ 0 ] = new FragmentNews();
  31. fragments[ 1 ] = new FragmentPostbar();
  32. fragments[ 2 ] = new FragmentQuestion();
  33. fragments[ 3 ] = new FragmentPhoto();
  34. getFragmentManager().beginTransaction().add(R.id.main_fragment,fragments[ 1 ])
  35. .add(R.id.main_fragment,fragments[ 2 ]).add(R.id.main_fragment,fragments[ 3 ]).add(R.id.main_fragment,fragments[ 0 ]).commit();
  36. newsClick( null );
  37. }
  38.   
  39. public   void newsClick(View view){
  40. getFragmentManager().beginTransaction().hide(fragments[ 1 ])
  41. .hide(fragments[ 2 ]).hide(fragments[ 3 ]).show(fragments[ 0 ]).commit();
  42.       
  43. getActionBar().setTitle( "News" );
  44. }
  45.       
  46. public   void postbarClick(View view){
  47. getFragmentManager().beginTransaction().hide(fragments[ 0 ])
  48. .hide(fragments[ 2 ]).hide(fragments[ 3 ]).show(fragments[ 1 ]).commit();
  49.           
  50. getActionBar().setTitle( "Tieba" );
  51. }
  52.       
  53. public   void questionClick(View view){
  54. getFragmentManager().beginTransaction().hide(fragments[ 0 ])
  55. .hide(fragments[ 1 ]).hide(fragments[ 3 ]).show(fragments[ 2 ]).commit();
  56. getActionBar().setTitle( "know" );
  57. }
  58.       
  59. public   void photoClick(View view){
  60. getFragmentManager().beginTransaction().hide(fragments[ 0 ])
  61. .hide(fragments[ 1 ]).hide(fragments[ 2 ]).show(fragments[ 3 ]).commit();
  62. getActionBar().setTitle( "Picture" );
  63. }
  64.       
  65. @Override  
  66. public   boolean onCreateOptionsMenu(Menu menu) {
  67. getMenuInflater().inflate(R.menu.menu, menu);
  68. return   true ;
  69. }
  70. @Override  
  71. public   boolean onMenuItemSelected( int featureId, MenuItem item) {
  72. switch (item.getItemId()) {
  73. case R.id.menu_share:
  74. Intent intent = new Intent(Intent.ACTION_SEND);
  75. intent.setType( "text/plain" );
  76. intent.putExtra(Intent.EXTRA_TEXT, "This is a news app that can customize keywords, welcome to try it" );
  77. startActivity(Intent.createChooser(intent, getTitle()));
  78. break ;
  79.   
  80. default :
  81. break ;
  82. }
  83. return   super .onMenuItemSelected(featureId, item);
  84. }
  85.   
  86. @Override  
  87. public   boolean onMenuOpened( int featureId, Menu menu) {
  88. if (featureId == Window.FEATURE_ACTION_BAR && menu != null ) {
  89. if (menu.getClass().getSimpleName().equals( "MenuBuilder" )) {
  90. try {
  91. Method m = menu.getClass().getDeclaredMethod( "setOptionalIconsVisible" , Boolean.TYPE);
  92. m.setAccessible( true );
  93. m.invoke(menu, true );
  94. } catch (Exception e) {
  95. e.printStackTrace();
  96. }
  97. }
  98. }
  99. return   super .onMenuOpened(featureId, menu);
  100. }
  101.   
  102. }

Download address : http://download..com/data/2089511

<<:  High imitation 360 mobile phone guard

>>:  IOS high imitation storm video player app source code

Recommend

In 5 years, 20 years...which workers will be threatened by big AI models?

What impact will large language models (LLMs) lik...

How to become a great advertising marketer?

Those who have watched the American TV series &qu...

"Without Office, WPS will make more money"

How popular is WPS in the country? An office soft...

How to create a hit product?

A good product can increase the probability of be...

How to push messages to APP (I)

With the development of the Internet and the cont...

Are the cotton swabs used for nucleic acid testing poisonous? Rumor!

March 28 Shanghai begins a new round of nucleic a...

User operation: user growth under growth hacker thinking

The e-commerce track is about innovation and iter...

An Shihao appointed head of Volkswagen North American sales

According to foreign media reports, Volkswagen Gr...

Whoosh~Eeh? They seemed to smell the "smell" of the universe...

The universe, this mysterious and vast space, alw...

Don't put away your thick clothes! Strong cold air will bring "swooping" cooling

Starting this Monday Sichuan Basin, Shaanxi, Yunn...