0

Activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </ListView>

        <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:fitsSystemWindows="true"
            app:menu="@menu/menu_category"/>
    </android.support.v4.widget.DrawerLayout>

MainActivity.java:

public class MainActivity extends Activity {

    public Elements title;
    public Elements description;
    public Elements date;
    public Elements link;
    public Elements imagesRec;
    public Document doc;
    public String siteUrl;
    public String imgSrcUrl;
    private ItemsAdapter adapter;
    private ListView lv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lv = findViewById(R.id.listView1);
        final ArrayList<ItemsClass> titleList = new ArrayList<>();
        adapter = new ItemsAdapter(this, titleList);

        DrawerLayout mDrawerLayout = findViewById(R.id.drawer_layout);
        NavigationView navigationView = findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(
                new NavigationView.OnNavigationItemSelectedListener() {
                    @Override
                    public boolean onNavigationItemSelected(MenuItem menuItem) {
                        menuItem.setChecked(true);
                        mDrawerLayout.closeDrawers();

                        int id = menuItem.getItemId();

                        switch (id) {
                            ...
                });
    }
}

Манифест:

    <application
        android:allowBackup="true"
        android:icon="@mipmap/logo_ibd"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/logo_ibd_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Content">
        </activity>
    </application>

</manifest>

На каком-то из этапов разработки заметил, что исчезла верхняя панель приложения, там где обычно располагается поиск, меню и т.д. Не пойму, в чем причина. Как вернуть ее на место?

2 ответа 2

1

Скорее всего у вас AppTheme наследует тему без ActionBar. Возможно у вас вот так:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

В данном случае стоит использовать Toolbar, т.к. ActionBar уже давно устарел

1
  • В style.xml прописано <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 29 авг 2018 в 7:47
1

Разобрался. Нужно было заменить строку в MainActivity.java

public class MainActivity extends Activity

на:

public class MainActivity extends AppCompatActivity

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими пользовательским соглашением, политикой конфиденциальности и политикой о куки

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.