Блог

Справочник рыбака на Kotlin: Урок 11 и 12

https://youtu.be/jTt1ja0r8rwhttps://youtu.be/5eJWUWKQMXQ MainActivity.kt import android.content.res.TypedArray import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.Gravity import android.view.MenuItem import android.widget.Toast import androidx.core.view.GravityCompat import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.navigation.NavigationView import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.main_content.* class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener{ var adapter: MyAdapter? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) nav_view.setNavigationItemSelectedListener (this) var list = ArrayList<ListItem>() list.addAll(fillArras(resources.getStringArray(R.array.fish), resources.getStringArray(R.array.fish_content),getImageId(R.array.fish_image_array))) rcView.hasFixedSize() rcView.layoutManager = LinearLayoutManager(this) adapter = MyAdapter(list,this) rcView.adapter = adapter } override fun onNavigationItemSelected(item: MenuItem): Boolean { when(item.itemId){ R.id.id_fish -> {… Подробнее »Справочник рыбака на Kotlin: Урок 11 и 12

Энциклопедия “Do You Know?” Урок 3

MenuFragmentList.java import android.graphics.Typeface; import android.os.Bundle; import android.text.Spannable; import android.text.SpannableString; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.SubMenu; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import com.google.android.material.navigation.NavigationView; /** * Created by mxn on 2016/12/13. * MenuListFragment */ public class MenuFragmentList extends Fragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view… Подробнее »Энциклопедия “Do You Know?” Урок 3

Справочник рыбака на Kotlin: Урок 10

MainActivity.kt import android.content.res.TypedArray import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.MenuItem import android.widget.Toast import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.navigation.NavigationView import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.main_content.* class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener{ var adapter: MyAdapter? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) nav_view.setNavigationItemSelectedListener (this) var list = ArrayList<ListItem>() list.addAll(fillArras(resources.getStringArray(R.array.fish), resources.getStringArray(R.array.fish_content),getImageId(R.array.fish_image_array))) rcView.hasFixedSize() rcView.layoutManager = LinearLayoutManager(this) adapter = MyAdapter(list,this) rcView.adapter = adapter } override fun onNavigationItemSelected(item: MenuItem): Boolean { when(item.itemId){ R.id.id_fish -> { Toast.makeText(this,”Id fish”,Toast.LENGTH_SHORT).show() adapter?.updateAdapter(fillArras(resources.getStringArray(R.array.fish), resources.getStringArray(R.array.fish_content),getImageId(R.array.fish_image_array))) }… Подробнее »Справочник рыбака на Kotlin: Урок 10

Do You Know? / Энциклопедия / Урок 1

Библиотека для меню: FlowingDrawer Копируем эти строчки в наш: build.gradle (Module: app) implementation ‘com.mxn.soul:flowingdrawer-core:2.1.0’implementation ‘com.nineoldandroids:library:2.4.0’   >>>Ссылка на библиотеку FlowingDrawer<<< MainActivity.java import androidx.appcompat.app.AppCompatActivity;import androidx.fragment.app.FragmentManager;import android.os.Bundle;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupMenu(); } private void setupMenu() { FragmentManager fm = getSupportFragmentManager(); MenuFragmentList mMenuFragment = (MenuFragmentList) fm.findFragmentById(R.id.id_container_menu); if (mMenuFragment == null) { mMenuFragment = new MenuFragmentList(); fm.beginTransaction().add(R.id.id_container_menu, mMenuFragment).commit(); } }} MenuFragmentList.java import android.os.Bundle;import android.view.LayoutInflater;import… Подробнее »Do You Know? / Энциклопедия / Урок 1

Справочник рыбака на Kotlin: Урок 9

MainActivity.kt import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.view.MenuItem import android.widget.Toast import androidx.recyclerview.widget.LinearLayoutManager import com.google.android.material.navigation.NavigationView import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.main_content.* import java.util.ArrayList class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener{ override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) nav_view.setNavigationItemSelectedListener (this) var list = ArrayList<ListItem>() list.add(ListItem(R.drawable.som,”Сом”,”чварчрпчаптчапт чапрапр ыарпчапрча”)) list.add(ListItem(R.drawable.nalim,”Налим”,”чварчрпчаптчапт чапрапр ыарпчапрча”)) list.add(ListItem(R.drawable.shuca,”Щука”,”чварчрпчаптчапт чапрапр ыарпчапрча”)) list.add(ListItem(R.drawable.caras,”Карась”,”чварчрпчаптчапт чапрапр ыарпчапрча”)) rcView.hasFixedSize() rcView.layoutManager = LinearLayoutManager(this) rcView.adapter = MyAdapter(list,this) } override fun onNavigationItemSelected(item: MenuItem): Boolean { when(item.itemId){ R.id.id_fish -> Toast.makeText(this,”Id fish”,Toast.LENGTH_SHORT).show() R.id.id_na ->… Подробнее »Справочник рыбака на Kotlin: Урок 9

Сенсоры в Android:Гироскоп и Акселерометр

MainActivity.java import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.ImageView; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private SensorManager sm; private Sensor s; private ImageView im; private TextView tv; private SensorEventListener sv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tv = findViewById(R.id.tv); im = findViewById(R.id.im); sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); if(sm !=null)s = sm.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); sv = new SensorEventListener() { @Override public void… Подробнее »Сенсоры в Android:Гироскоп и Акселерометр

Парсинг сайтов урок 4

MainActivity.java import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.ListView; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private Document doc; private Thread secThread; private Runnable runnable; private ListView listView; private CustomArrayAdapter adapter; private List<ListItemClass> arrayList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { listView = findViewById(R.id.listView); arrayList = new ArrayList<>(); adapter =… Подробнее »Парсинг сайтов урок 4

Игра “Рулетка” : Android Studio уроки

MainActivity.java import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.view.animation.Animation;import android.view.animation.DecelerateInterpolator;import android.view.animation.RotateAnimation;import android.widget.ImageView;import android.widget.TextView;import java.util.Random;public class MainActivity extends AppCompatActivity { private TextView tvResult; private ImageView rul; private Random random; private int old_deegre = 0; private int deegre = 0; private static final float FACTOR = 4.86f; private String[] numbers = {“32 RED”,”15 BLACK”,”19 RED”,”4 BLACK”, “21 RED”,”2 BLACK”,”25 RED”,”17 BLACK”, “34 RED”, “6 BLACK”,”27 RED”,”13 BLACK”,”36 RED”,”11 BLACK”,”30 RED”, “8 BLACK”,”23 RED”,”10 BLACK”,”5 RED”,”24… Подробнее »Игра “Рулетка” : Android Studio уроки

Парсинг сайтов: Урок 3

MainActivity.java import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.ListView; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private Document doc; private Thread secThread; private Runnable runnable; private ListView listView; private CustomArrayAdapter adapter; private List<ListItemClass> arrayList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); init(); } private void init() { listView = findViewById(R.id.listView); arrayList = new ArrayList<>(); adapter =… Подробнее »Парсинг сайтов: Урок 3