zoukankan      html  css  js  c++  java
  • Android Crash Learning

    Android Crash Learning

    1.LinearLayout

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <ImageView
            android:layout_width="160dp"
            android:layout_height="90dp"
            android:src="@drawable/react" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="按钮" />
    </LinearLayout>
    

    2.RelativeLayout

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <TextView
            android:layout_margin="50dp"
            android:id="@+id/greeting"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Greeting!"
            android:textSize="50dp"/>
    
        <TextView
            android:layout_margin="50dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="GoodBye!"
            android:layout_below="@+id/greeting"
            android:textSize="50dp"/>
    </RelativeLayout>
    

    3.Toast

    Toast.makeText(getApplicationContext(), "哈哈哈", Toast.LENGTH_LONG).show();
    

    4.Click

     public void btn1(View view) {
     	Toast.makeText(getApplicationContext(), "哈哈哈", Toast.LENGTH_LONG).show();
     }
     // 接着设置一下按钮的onClick属性
    

    5.Intent跳转

    Intent intent = new Intent(LoginActivity.this, CommonMenuActivity.class);
    startActivity(intent);
    

    在manifest中需要声明

    <activity android:name=".pages.CommonMenuActivity"></activity>
    

    6.携带数据跳转

    // 传输数据
    Intent intent = new Intent(LoginActivity.this, CommonMenuActivity.class);
    intent.putExtra("key", "value");
    
    // 获取数据
    Bundle bundle = getIntent().getExtras();
    bundle.getString("key");
    
    // 继承Serializable的对象可以直接
    intent.putExtra("key", obj);
    Item item = (Item)bundle.getSerializable("key");
    

    7.API调用

    见Github使用OkHttp
    
  • 相关阅读:
    bootstrap按钮
    bootstrap输入框组
    bootstrap单选
    bootstrap复选框
    bootstrap输入框
    bootstrap浮动
    HO引擎近况20201017
    C#.NET项目中引用EXCEL报错的问题
    MATLAB实例:读取Fashion MNIST数据,保存为.mat文件,并展示部分样例
    MATLAB实例:BP神经网络用于回归任务
  • 原文地址:https://www.cnblogs.com/littlepage/p/13872277.html
Copyright © 2011-2022 走看看