Ответы пользователя по тегу Android
  • Как добавить в боковое меню activity?

    @bot8
    Android noob
    Ну написано же в чем ошибка
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.admin.ulmxsd/com.example.admin.ulmxsd.kurs1}; have you declared this activity in your AndroidManifest.xml?
    Ответ написан
    1 комментарий
  • Как сделать в RecyclerView ссылку на сайт?

    @bot8
    Android noob
    Для TextView с ссылкой добавьте атрибут android:autoLink=«web»
    Ответ написан
    Комментировать
  • Как отобразить список и дополнительный текстовый блок на экране?

    @bot8
    Android noob
    Думаю, вам стоит использовать паралакс эффект чтобы ваш LinearLayout с TextView при скролле уходил с экрана. Почитайте как это сделать здесь или там

    simple_coordinator.gif
    Ответ написан
    Комментировать
  • Как получить список друзей, находящихся в сети (VKApi)?

    @bot8
    Android noob
    VKRequest request = new VKRequest("friends.getOnline");


    В ответ вы получите список из id друзей текущего пользователя которые находятся в онлайне. Можете посмотреть что вы получите.
    Ответ написан
    Комментировать
  • Почему возникает ошибка при попытке открыть настройки живых обоев?

    @bot8
    Android noob
    Попробуйте изменить в манифесте вот это <activity android:name=".SettingsActivity" />

    чтобы было так

    <activity android:name=".SettingsActivity" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
    </activity>
    Ответ написан
  • Что нужно сделать, чтобы развиваться?

    @bot8
    Android noob
    Если нет идеи, то напиши аналог какого-нибудь существующего и с какими-то новыми фишками.
    > Плюс очень сложно писать, ради того чтобы писать
    Я правильно понял, что ты не получаешь удовольствие от процесса? Если да, то тогда стоит задуматься - а надо ли это вообще тебе?
    Ответ написан
    1 комментарий
  • Как убрать разделительные полосы в списке?

    @bot8
    Android noob
    Используй RecyclerView и их не будет
    Ответ написан
    Комментировать
  • Как добавить кнопки в toolbar?

    @bot8
    Android noob
    Вот тут все подробно описано.
    Ответ написан
    Комментировать
  • Как реализовать отображение изображений в RecyclerView как на картинке?

    @bot8 Автор вопроса
    Android noob
    Случайно наткнулся на библиотеку, которая может быть решением. Еще не проверял.
    QuiltViewLibrary
    Ответ написан
  • Положить в tabs recycler view?

    @bot8
    Android noob
    Уже был такой вопрос

    А то что ниже, все же оставлю здесь

    MainActivity.java

    public class MainActivity extends AppCompatActivity {
    
        private Toolbar mToolBar;
        private ViewPager mViewPager;
        private TabLayout mTabLayout;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            setContentView(R.layout.activity_main);
            mTabLayout = (TabLayout) v.findViewById(R.id.tablayout);
            mToolBar = (Toolbar) v.findViewById(R.id.toolbar);
            mViewPager = (ViewPager) v.findViewById(R.id.viewpager);
            ((AppCompatActivity) getActivity()).setSupportActionBar(mToolBar);
            ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
            actionBar.setDisplayHomeAsUpEnabled(true);
            ViewPagerAdapter adapter = new ViewPagerAdapter(getFragmentManager());
            adapter.add(new MyFragment(), "First fragment"));                       
            adapter.add(new MyFragment(), "Second fragment"));
            }
        }


    MyFragment.java

    public class MyFragment extends Fragment {
        private RecyclerView mRecyclerView;
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.fragment, container, false);
            mRecyclerView =(RecyclerView) view.findViewById(R.id.my_fragment);
            mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
            return view;
        }
    }


    activity_main.xml

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways" />
            <android.support.design.widget.TabLayout
                android:id="@+id/tablayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabGravity="fill"
                app:tabMode="fixed" />
        </android.support.design.widget.AppBarLayout>
        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    </android.support.design.widget.CoordinatorLayout>


    my_fragment.xml

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.RecyclerView
    	xmlns:android="http://schemas.android.com/apk/res/android"
    	xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/recycler_view">
    </android.support.v7.widget.RecyclerView>
    Ответ написан
  • Как сверстать подобный макет?

    @bot8
    Android noob
    d6055785cb734be9b704740eb77a003f.png
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="#D4D7DC"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center_horizontal">
        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginTop="30dp">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="dark"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="10dp"
                android:layout_marginBottom="20dp"
                android:text="Какой-то текст..."
                android:textSize="17dp"/>
        </android.support.v7.widget.CardView>
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="250dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:weightSum="100">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:layout_marginBottom="-6dp"
                android:layout_marginTop="-6dp"
                android:src="@drawable/Desert" />
        </LinearLayout>
        <android.support.v7.widget.CardView
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="dark"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="10dp"
                android:layout_marginBottom="20dp"
                android:text="Какой-то Другой текст..."
                android:textSize="17dp"/>
        </android.support.v7.widget.CardView>
    </LinearLayout>
    Ответ написан
    3 комментария
  • Как заставить адаптер брать данные из ArrayList в обратном порядке?

    @bot8
    Android noob
    ArrayList<String> List = new ArrayList<>(); // Исходный ArrayList
            ArrayList<String> newList = new ArrayList<>(); 
            List.add("Первый");  // Заполнил List
            List.add("Второй");
            List.add("Третий");
            
            for (int i=List.size()-1; i>=0; i--) // Перевернул List и засунул 
                newList.add(List.get(i));        // в newList
          
            for(String str : newList)
                System.out.println(str);


    или так

    public class MyAdapter extends ArrayAdapter<String> {
            private List<String> list;
    
        public MyAdapter(Context context, int resource, List<String> list) {
            super(context, resource, list);
            this.list=list;
    
        }
    
        @Override
        public int getCount() {
            return list.size();
        }
    
        @Override
        public String getItem(int position) {
            return list.get((position-list.size())*-1-1);
        }
    }
    Ответ написан