Home  >  Article  >  Java  >  Sharing of materials (courseware, source code) of Shangxuetang’s zero-based introductory video tutorial on Android development

Sharing of materials (courseware, source code) of Shangxuetang’s zero-based introductory video tutorial on Android development

黄舟
黄舟Original
2017-12-04 11:25:512794browse

Android is an open source, Linux-based mobile device operating system, mainly used in mobile devices, such as smartphones and tablets. It only takes two days for learners to master the basic knowledge of Android development and step into the door of Android development.

Sharing of materials (courseware, source code) of Shangxuetang’s zero-based introductory video tutorial on Android development

Course playback address: http://www.php.cn/course/397.html

The teacher’s teaching style:

The teacher’s lectures are simple, clear, layer-by-layer analysis, interlocking, rigorous argumentation, rigorous structure, and use the logical power of thinking to attract students’ attention Strength, use reason to control the classroom teaching process. By listening to the teacher's lectures, students not only learn knowledge, but also receive thinking training, and are also influenced and influenced by the teacher's rigorous academic attitude

The more difficult point in this video is UI_Spinner, a commonly used component With adapter mode:

layout file

<Spinner        android:id="@+id/spinner"
        android:layout_width="112dp"
        android:layout_height="85dp"
        android:entries="@array/spinner"
        android:spinnerMode="dialog"
        tools:layout_constraintTop_creator="1"
        android:layout_marginStart="59dp"
        android:layout_marginTop="125dp"
        tools:layout_constraintLeft_creator="1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="59dp" />
    <!--
    entries用来选定下拉列表的内容,在string.xml中配置
    spinnerMode用来选择弹出列表的形式,这里dialog指的是弹出窗口
    -->

resource file

<resources>
    <string name="app_name">Spinner</string>
    <string-array name="spinner">
        <item>丑逼</item>
        <item>贱婢</item>
        <item>母猪</item>
    </string-array></resources>
通过代码动态添加的方式-BaseAdapter 
布局文件
<Spinner        android:id="@+id/spinner"
        android:layout_width="112dp"
        android:layout_height="85dp"
        android:spinnerMode="dialog"
        tools:layout_constraintTop_creator="1"
        android:layout_marginStart="59dp"
        android:layout_marginTop="125dp"
        tools:layout_constraintLeft_creator="1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="59dp" />
Java代码
package com.example.administrator.spinner;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class MainActivity extends AppCompatActivity {
    private  String[] ss=new String[]
            {                    "北京",                    "上海",                    "深圳"
            };    private List<String> list=new ArrayList<String>();    @Override
    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        list.add("明明");
        list.add("静静");
        list.add("爱爱");

        Spinner spinner=(Spinner) findViewById(R.id.spinner);
        BaseAdapter adapter = new MyAdapter();
        spinner.setAdapter(adapter);
    }    private class MyAdapter  extends  BaseAdapter{
        @Override
        public  int getCount()
        {            return ss.length;   //可换成list.size()
        }        @Override
        public  Object getItem(int position)
        {            return null;
        }        @Override
        public  long getItemId(int position)
        {            return 0;
        }        @Override
        public View getView(int position, View convertView , ViewGroup parent)
        {
            TextView textView=new TextView(MainActivity.this);
            textView.setText(ss[position]);   //可换成list.get(position)
            return textView;
        }
    }
}
ArrayAdapter直接继承BaseAdapter
Spinner spinner=(Spinner) findViewById(R.id.spinner);//        BaseAdapter adapter = new MyAdapter();
        ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,ss);
        spinner.setAdapter(adapter);
spinner的监听事件
Spinner spinner=(Spinner) findViewById(R.id.spinner);
       BaseAdapter adapter = new MyAdapter();

        spinner.setAdapter(adapter);
       spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {           @Override
           public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {               //position为当前选择的值得索引
               Toast.makeText(MainActivity.this,ss[position],Toast.LENGTH_SHORT).show();
           }           @Override
           public void onNothingSelected(AdapterView<?> parent) {

           }
       });

return here Everyone recommended the download of the information: http://www.php.cn/xiazai/learn/1940

. The resource includes video courseware and ppt:

  1. Document 16-20.doc when the video is released

  2. Document 24-25.doc when the video is released

  3. Video release Document 31-32.doc

  4. Document 33-36.doc

when the video was released

The above is the detailed content of Sharing of materials (courseware, source code) of Shangxuetang’s zero-based introductory video tutorial on Android development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn