Change the Actionbar title in old versions

1

Hello, I have four screens in my android application and I want every screen in the action bar to have a different name. I tried changing the title using getActionBar().setTile() :

Only as I have API 9 as a minimum version and I can not use it. Is there any other option that works from API 9?

    
asked by anonymous 13.11.2016 / 21:53

1 answer

3

For older versions you will need to use % with% .

See that your class will inherit from getSupportActionBar() . or ActionBarActivity or instead of AppCompatActivity :

public class MinhaAtividade extends ActionBarActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setTitle("Meu titulo");            
        setContentView(R.layout.activity_minha_tela);
    }

    // ... demais métodos
}
    
13.11.2016 / 22:17