Remove the title bar from the new android project and create a new android project.
1. Create a new android application project
Select none for theme and check to create a Blank Activity.
Run as shown in:
2. To remove the title bar, change the MainActivity topic style of Manifestr.
> Styles. xml
Start to <style name = "AppTheme" parent = "AppBaseTheme">
Change to: <style name = "AppTheme" parent = "android: Theme. Light. NoTitleBar"> // The title is white.
When You do this, the following error occurs: Caused by: java. lang. IllegalStateException: You need to use a Theme. AppCompat theme (or descendant) with this activity.
3. The reason is that the public class MainActivity extends ActionBarActivity inherits the class with the title of ActionBarActivity when it is created, and an error is reported.
Modify the inheritance FragmentActivity and handle the corresponding error.
The Code is as follows:
1 package com.example.abc; 2 3 import android.support.v7.app.ActionBarActivity; 4 import android.support.v7.app.ActionBar; 5 import android.support.v4.app.Fragment; 6 import android.support.v4.app.FragmentActivity; 7 import android.os.Bundle; 8 import android.view.LayoutInflater; 9 import android.view.Menu;10 import android.view.MenuItem;11 import android.view.View;12 import android.view.ViewGroup;13 import android.os.Build;14 15 public class MainActivity extends FragmentActivity {16 17 @Override18 protected void onCreate(Bundle savedInstanceState) {19 super.onCreate(savedInstanceState);20 setContentView(R.layout.activity_main);21 22 if (savedInstanceState == null) {23 getSupportFragmentManager().beginTransaction()24 .add(R.id.container, new PlaceholderFragment()).commit();25 }26 }27 28 // @Override29 // public boolean onCreateOptionsMenu(Menu menu) {30 //31 // // Inflate the menu; this adds items to the action bar if it is present.32 // getMenuInflater().inflate(R.menu.main, menu);33 // return true;34 // }35 //36 // @Override37 // public boolean onOptionsItemSelected(MenuItem item) {38 // // Handle action bar item clicks here. The action bar will39 // // automatically handle clicks on the Home/Up button, so long40 // // as you specify a parent activity in AndroidManifest.xml.41 // int id = item.getItemId();42 // if (id == R.id.action_settings) {43 // return true;44 // }45 // return super.onOptionsItemSelected(item);46 // }47 48 /**49 * A placeholder fragment containing a simple view.50 */51 public static class PlaceholderFragment extends Fragment {52 53 public PlaceholderFragment() {54 }55 56 @Override57 public View onCreateView(LayoutInflater inflater, ViewGroup container,58 Bundle savedInstanceState) {59 View rootView = inflater.inflate(R.layout.fragment_main, container,60 false);61 return rootView;62 }63 }64 65 }
Run properly: