Android Learning One Lesson One Obtain

Android Learning One Lesson One Obtain
insert image description here

introduction

This semester I took Android development as part of my course and gained an in-depth understanding of this powerful mobile application development platform. Through study and practice, I have a basic understanding of the Android development process, core concepts and common technologies. In this blog, I will share my learning experience and experience in Android development, as well as my outlook on future development.

1. Getting Started

1.1 Getting Started with Android Development

In the Android course this semester, I first learned the basic concepts and architecture of Android. I understand the components and life cycle of Android applications, such as Activity, Fragment and Service. By writing a simple Hello World application, I have mastered the basic process and tools of Android development, such as Android Studio and layout editor. This gave me a solid foundation to learn and practice more advanced Android development techniques in depth. ``

1.2 User interface design and layout

In Android development, good user interface design is crucial. I learned Android's layout system, including LinearLayout, RelativeLayout and ConstraintLayout. And the basic controls of Android, TextView text control, EditText, Image control, Button control. I learned how to use XML to define user interfaces, and mastered the use of common UI components, such as buttons, text boxes, and image views. Through hands-on projects, I learned to create beautiful, friendly interfaces.

1.3 Data storage and persistence

Android applications usually need to interact with and persist data. I read and write file storage, learned to use SQLite database for local data storage, and can perform simple addition, deletion, modification and query operations. I also learned how to use SharedPreferences for lightweight data storage. These technologies enable me to implement efficient management and storage of data in the application.

1.4 Network communication and data acquisition

Communicating with the network and fetching data is a very common requirement in modern mobile applications. I learned how to use Android's network API for HTTP requests and data parsing. I learned about commonly used network libraries such as Retrofit and Volley, and learned to handle asynchronous operations for network requests. This allows me to develop powerful applications that interact with the server for data. I also learned how to use OAuth for user authentication and authorization, improving the security of the application.

1.5 Conclusion

Through the study of Android development this semester, I have a deep understanding of this powerful mobile application development platform and gained practical development experience. I have mastered the basic process, core concepts and common technologies of Android development, and can develop feature-rich and user-friendly Android applications. I am full of confidence in the future development of Android, and I look forward to continuing in-depth research and exploration in future practice, and constantly improving my Android development skills.

2. Learning outcomes

2.1 Learning experience and methods

1. Learning is your own business, and anything else is just to assist you. The important thing is your own learning attitude.
2. Set your own learning stage goals, you must ensure that you are really learning and absorbing, and remember to learn effectively.
3. In the process of real learning, it must be a little painful. Persevere, you will gain a lot.
4. Work hard and think more

2.2 Implement a simple "Hello, World!" in Android application

  1. In the MainActivity.java file, add the following code to the onCreate() method:
@Override
protected void onCreate(Bundle savedInstanceState) {
    
    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView textView = findViewById(R.id.textView);
    textView.setText("Hello, World!");
}

2. Make sure you have a TextView component in your layout file and assign it an id attribute like so:

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="24sp"
    android:textStyle="bold"
    android:layout_gravity="center"
    />

Of course, this is just a simple example, and more customization and function extensions can be made as needed.

2.3 Project display (partial)

insert image description here
*
insert image description here
![Insert picture description here](https://img-blog.csdnimg.cn/2620264dee734c829c08e50805740b1d.png
Part of the code, the complete code can be obtained by leaving a message

package com.example.administrator.myshare;

import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LineActivity extends AppCompatActivity {
    
    
    Button action_show,action_hide;
    ActionBar actionBar;
    //声明控件
    private Button mBtnLogin;
    private Button mBtnTest;
    private EditText mEtUser;
    private EditText mEtPassword;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    
    

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_line);

        //找到控件
        mBtnLogin = (Button)findViewById(R.id.btn_login);
        mBtnTest = (Button)findViewById(R.id.btn_Test);
        mEtUser= (EditText)findViewById(R.id.et_1);
        mEtPassword  = (EditText)findViewById(R.id.et_2);
        //实现跳转 - - - 方法一

        mBtnTest.setOnClickListener(new View.OnClickListener() {
    
    
            @Override
            public void onClick(View view) {
    
    
                Intent intent = null;
                intent = new Intent(LineActivity.this, LoginActivity.class);
                startActivity(intent);
            }
        });
        //匹配对应的用户名
        mBtnLogin.setOnClickListener(new View.OnClickListener() {
    
    
            @Override
            public void onClick(View view) {
    
    
                String username = mEtUser.getText().toString();
                String password = mEtPassword.getText().toString();
                //设置弹出内容
                String ok = "登录成功";
                String fail = "登录失败,账户或密码错误";
                Intent intent = null;
                if(username.equals("a")&&password.equals("123")){
    
    
                    Toast.makeText(getApplicationContext(), ok, Toast.LENGTH_SHORT).show();
                    intent =  new Intent(LineActivity.this,MainActivity.class);
                    intent.putExtra("zh", username);
                    intent.putExtra("mm",password);
                    startActivity(intent);
                }else{
    
    
                    Intent intent1 = getIntent();
                    String a1 = intent1.getStringExtra("zh");
                    String a2 = intent1.getStringExtra("mm");
                    if(username.equals(a1)&&password.equals(a2)){
    
    
                        Toast.makeText(getApplicationContext(),ok,Toast.LENGTH_SHORT).show();
                        intent1 =  new Intent(LineActivity.this,LoginActivity.class);
                        intent1.putExtra("zh", username);
                        intent1.putExtra("mm",password);
                        startActivity(intent1);
                    }else{
    
    
                        Toast toast  = Toast.makeText(getApplicationContext(),fail,Toast.LENGTH_SHORT);
                        toast.setGravity(Gravity.CENTER,0,0);
                        toast.show();
                    }
                }
            }
        });
    }
}


3. Summary

This is a brief Android one lesson one get blog post, 2023, keep loving and go to the mountains and seas.

References:
Android Developers Official Website

Guess you like

Origin blog.csdn.net/weixin_49185262/article/details/131370482