Android应用开发基础“一课一得”

         Android是目前最流行的移动操作系统之一,它具有开放性、灵活性和丰富的功能,吸引了众多的开发者和用户。在本学期的课程中,我有幸接触了Android应用开发的基础知识和技能,通过使用Android Studio代码开发工具,完成了七个作业项目,分别是“简单的计算器作业项目”、“页面跳转与生命周期作业项目”、“相对布局作业项目”、“一个注册页面作业项目”、“一个登陆后主界面作业项目”、“一个简单的相册作业项目”和“一个简单的社交软件框架作业项目”。在这个过程中,我不仅学习了Android的基本概念、控件、布局、事件处理、界面跳转、数据传递、服务、广播、存储、网络等方面的知识,还锻炼了自己的编程思维和解决问题的能力。在此,我想分享一下我的学习心得和体会。

        首先,我认为Android应用开发是一门很有趣和有挑战性的课程,它让我感受到了编程的乐趣和创造力。通过Android Studio这个强大的集成开发环境,我可以快速地创建和运行Android应用程序,并且可以利用其提供的各种工具和插件来辅助开发和调试。例如,我可以使用Layout Editor来可视化地设计界面布局,使用Logcat来查看程序运行时的日志信息,使用Debugger来设置断点和监视变量,使用Emulator来模拟不同型号和版本的手机设备,使用Profiler来分析程序性能和资源消耗等。这些工具让我在开发过程中更加高效和便捷。

        其次,我认为Android应用开发是一门很实用和有价值的课程,它让我掌握了移动应用开发的基本技术和方法。通过完成七个作业项目,我对Android应用程序的结构和运行机制有了更深入的理解。例如,我了解了Activity是Android应用程序中最基本的组件之一,它代表了一个用户界面,并且有自己的生命周期。我学会了如何使用Intent来实现Activity之间的跳转和数据传递,以及如何使用Bundle来封装数据。我还学会了如何使用Service来执行后台任务,并且如何使用BroadcastReceiver来接收和发送广播消息。此外,我还学会了如何使用各种控件来实现用户交互功能,如Button, TextView, EditText, ImageView, ListView, RecyclerView等,并且如何使用不同的布局来排列控件,如LinearLayout, RelativeLayout, ConstraintLayout等。我还学会了如何使用SharedPreferences, SQLite, File等方式来存储数据。

        最后,我认为Android应用开发是一门很有前景和有潜力的课程,它让我拓展了自己的知识视野和技能范围。通过学习Android应用开发,我不仅巩固了Java编程语言的基础知识,还接触了一些新颖和高级的技术和概念。

        总之,在本学期的Android应用开发基础课程中,我收获了很多知识和技能,也体验了很多乐趣和挑战。我认为这门课程不仅是对我专业知识的一次补充和提升,也是对我个人兴趣和爱好的一次培养和满足。我希望在今后的学习和工作中,我能够继续深入学习Android应用开发的相关知识和技术,并且能够利用所学的知识和技能,开发出更多有用和有趣的Android应用程序。

Android Studio 是基于 IntelliJ IDEA 的官方 Android 应用开发集成开发环境 (IDE)。 除了 IntelliJ 强大的代码编辑器和开发者工具,Android Studio 提供了更多可提高 Android 应用构建效率的功能,例如:基于 Gradle 的灵活构建系统;快速且功能丰富的模拟器;可针对所有 Android 设备进行开发的统一环境;Instant Run,可将变更推送到正在运行的应用,无需构建新的 APK;可帮助你构建常用应用功能和导入示例代码的代码模板和 GitHub 集成;丰富的测试工具和框架;可捕捉性能、易用性、版本兼容性以及其他问题的 Lint 工具;C++ 和 NDK 支持;内置对 Google 云端平台的支持,可轻松集成 Google Cloud Messaging 和 App 引擎。

目前为止,Android Studio 4.1 稳定版是最新的版本,全方位提升了开发体验。Android Studio 4.1 的一些亮点如下: 引入全新的 Database Inspector,用于查询应用的数据库;支持浏览使用 Dagger 或 Hilt 进行依赖项注入的项目;支持在 Android 项目中使用 TensorFlow Lite 模型,进一步增强了对设备端机器学习的支持。我们还对 Apply Changes 进行了更新,以加快部署速度。我们根据大家的反馈进行了一些更改,引入了新的原生内存性能分析器和独立分析工具来为游戏开发者提供助力。

Android Studio是谷歌推出的一个Android集成开发工具,基于IntelliJ IDEA. 类似 Eclipse ADT,Android Studio 提供了集成的 Android 开发工具用于开发和调试。Android Studio能够在Linux、Windows、macOS上运行,支持Java、Kotlin、Flutter等语言开发。

在IDEA的基础上,Android Studio 提供:

  • 基于Gradle的构建支持
  • Android 专属的重构和快速修复
  • 提示工具以捕获性能、可用性、版本兼容性等问题
  • 支持ProGuard 和应用签名
  • 基于模板的向导来生成常用的 Android 应用设计和组件
  • 功能强大的布局编辑器,可以让你拖拉 UI 控件并进行效果预览

优点

1、Google推出的

毫无疑问,这个是它的最大优势,Android Stuido是Google推出,专门为Android“量身订做”的,是Google大力支持的一款基于IntelliJ idea改造的IDE,google的工程师团队肯定会不断完善,上升空间非常大,这个应该能说明为什么它是Android的未来。

2、速度更快

Eclipse的启动速度、响应速度、内存占用一直被诟病,相信大家这点应该深有体会,而且经常遇到卡死状态。Studio不管哪一个方面都全面领先Eclipse。这点可能在windows上没有表现出来,win上运行studio同样会出现卡顿现象,但这只能说win平台还没优化好,毕竟还没有发布正式版,或者说windows系统本身就很卡顿,你还能指望它做什么呢。

3、UI更漂亮

I/O上演示的那款黑色主题真是太棒了,极客范,Stuido自带的Darcula主题的炫酷黑界面实在是高大上,相比而言Eclipse下的黑色主题太low了。

4、更加智能

提示补全对于开发来说意义重大, Studio则更加智能,智能保存,从此再也不用每次都 Ctrl + S了。熟悉Studio以后效率会大大提升。

5、整合了Gradle构建工具

Gradle是一个新的构建工具,自Studio亮相之处就支持Gradle,可以说Gradle集合了Ant和Maven的优点,不管是配置、编译、打包都非常棒。

6、强大的UI编辑器

Android Studio的编辑器非常的智能,除了吸收Eclipse+ADT的优点之外,还自带了多设备的实时预览,相对这对Android开发者来说简直是神器啊。

7、内置终端

Studio内置终端,这对于习惯命令行操作的人来说简直是福音啊,再也不用来回切换了,一个Studio全部搞定。

8、更完善的插件系统

Studio下支持各种插件,如Git、Markdown、Gradle等等,你想要什么插件,直接搜索下载。

9、完美整合版本控制系统

安装的时候就自带了如GitHub, Git, SVN等流行的版本控制系统,可以直接check out你的项目。

由于Studio目前国内还未普及,所以如果你是新手可以直接学习Studio,上手了就比那些老手们多了一项技能,如果你是老手已经对eclipse操作情有独钟的话,没关系,Studio内置可以直接把快捷键设置成eclipse风格的。

缺点:

首先Studio目前仍未发布正式版,可能有些不稳定,但是用了这么久,发现的bug很少;其次从Eclipse迁移到Studio有学习成本,不过这对于一名开发者来说学无止境,而且不想学习的话可直接设置eclipse风格的快捷键;最后Studio官方解释暂不支持NDK,所以如果你的项目有使用NDK不建议使用。

Android Studio 4.1 包括以下新增及改进功能:

1、设计:Material Design 组件更新

2、开发:Database Inspector;直接在 Android Studio 中运行 Android 模拟器;Dagger 导航支持;使用 TensorFlow Lite 模型;

3、构建和测试:Android 模拟器 - 可折叠设备铰链信息支持;Apply Changes 更新;从 AAR 中导出 C/C++ 依赖项;原生代码崩溃报告符号化解析

4、优化:System Trace 界面改进;独立分析器;原生内存性能分析器

简单的计算器布局展示:

 

简单的计算器代码展示:

        前台activity.calculaltor.xml布置了计算器的基本页面

<?xml version="1.0" encoding="utf-8"?>
<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:background="#EEEEEE"
    android:orientation="vertical"
    android:padding="5dp"
    tools:context=".Calcula1torActivity">
 
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
 
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="@string/simple_calculator"
                android:textColor="@color/black"
                android:textSize="20sp" />
 
            <TextView
                android:id="@+id/tv_result"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:gravity="right|bottom"
                android:lines="3"
                android:text="0"
                android:textColor="@color/black"
                android:textSize="25sp"/>
 
 
            <GridLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:columnCount="4"
                android:rowCount="5">
 
                <Button
                    android:id="@+id/btn_cancel"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/cancel"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_divide"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/divide"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_multiply"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/multiply"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_clear"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/clear"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_seven"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/seven"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_eight"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/eight"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_nine"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/nine"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_plus"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/plus"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_four"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/four"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_five"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/five"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_six"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/six"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_minus"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/minus"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_one"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/one"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_two"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/two"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_three"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/three"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
<!--                <ImageButton-->
<!--                    android:id="@+id/id_sqrt"-->
<!--                    android:layout_width="0dp"-->
<!--                    android:background="#ccc"-->
<!--                    android:layout_height="@dimen/button_height"-->
<!--                    android:layout_columnWeight="1"-->
<!--                    android:scaleType="centerInside"-->
<!--                    android:src="@drawable/sqrt">-->
<!--                </ImageButton>-->
                <Button
                    android:id="@+id/btn_sqrt"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/sqrt"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_reciprocal"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/reciprocal"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_zero"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/zero"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_dot"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/dot"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
                <Button
                    android:id="@+id/btn_equal"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:layout_gravity="center"
                    android:text="@string/equal"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size">
                </Button>
 
            </GridLayout>
 
        </LinearLayout>
 
    </ScrollView>
 
</LinearLayout>

        后台CalculatorActivity.java完善了加减乘除等计算器功能:

package com.example.calculator;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
 
public class CalculatorActivity extends AppCompatActivity implements View.OnClickListener {
 
    //文本视图
    private TextView tv_result;
    //第一个操作数
    private String firstNum = "";
 
    //运算符
    private String operator = "";
 
    //第二个操作数
    private String secondNum = "";
 
    //当前运算结果
    private String result = "";
 
    //显示的文本内容
    private String showText = "";
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculator);
        //从布局文件中获取名叫tv_result的文本视图
        TextView tv_result = findViewById(R.id.tv_result);
 
        //下面给每个按钮控件都注册了点击监听器
        findViewById(R.id.btn_cancel).setOnClickListener(this);  //“清零”按钮
        findViewById(R.id.btn_divide) .setOnClickListener(this);   //"除法"按钮
        findViewById (R.id.btn_multiply).setOnClickListener(this);  //"乘法"按钮
        findViewById(R.id.btn_clear).setOnClickListener(this);  //"清除”按钮
        findViewById(R.id.btn_seven) .setOnClickListener(this);  //数字7
        findViewById(R.id.btn_eight).setOnClickListener (this);  //数字8
        findViewById(R.id.btn_nine).setOnClickListener(this);  //数字9
        findViewById(R.id.btn_plus).setOnClickListener (this);  //"加法"按钮
        findViewById(R.id.btn_four).setOnClickListener(this);  //数字4
        findViewById(R.id.btn_five).setOnClickListener (this);  //数字5
        findViewById(R.id.btn_six).setOnClickListener(this);  //数字6
        findViewById(R.id.btn_minus) .setOnClickListener(this);  //"减法"按钮
        findViewById(R.id.btn_one).setOnClickListener (this);  //数字1
        findViewById(R.id.btn_two) .setOnClickListener (this);  //数字2
        findViewById(R.id.btn_three).setOnClickListener(this);  //数字3
        findViewById(R.id.btn_reciprocal).setOnClickListener(this);  //求倒数按钮
        findViewById(R.id.btn_zero) .setOnClickListener(this); //数字0
 
    }
 
    @Override
    public void onClick(View v) {
        String inputText;
        //如果是开根号按钮
        if(v.getId() == R.id.btn_sqrt){
            inputText = "√";
        }else {
            //除了开根号之外的其他按钮
            inputText = ((TextView) v).getText().toString();
        }
        switch (v.getId()){
            // 点击清除按钮
            case R.id.btn_clear:
                break;
 
            // 点击取消按钮
            case R.id.btn_cancel:
                break;
 
            // 点击 加、减、乘、除 按钮
            case R.id.btn_plus:
            case R.id.btn_minus:
            case R.id.btn_multiply:
            case R.id.btn_divide:
                break;
 
            // 点击等号按钮
            case R.id.btn_equal:
                break;
 
            // 点击开根号按钮
            case R.id.btn_sqrt:
                break;
 
            // 点击求导数按钮
            case R.id.btn_reciprocal:
                break;
 
            //点击了其他按钮,包括数字和小数点
            default:
                //无运算符,则继续拼接第一个操作数
                // operator 运算符
                if(operator.equals("")){
                    firstNum = firstNum + inputText;
                }else {
                    //有运算符,则继续拼接第二个操作数
                    secondNum = secondNum + inputText;
                }
                refreshText(showText + inputText);
                break;
        }
    }
 
    //刷新文本显示
    private void refreshText(String text){
 
        //显示的文本内容
        showText = text;
        //tv_result = 文本视图
        tv_result.setText(showText);
    }
}

2.0一个简单的相册

2.1前台布局

<?xml version="1.0" encoding="utf-8"?>
<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">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">
        <androidx.viewpager2.widget.ViewPager2
            android:id="@+id/vp2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <RadioGroup
            android:id="@+id/RadioGroup"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:orientation="horizontal"
            android:gravity="center"
            android:layout_weight="1">

            <RadioButton
                android:id="@+id/B1"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginRight="10dp"
                android:button="@null"
                android:background="@drawable/button_selecltor"
                />
            <RadioButton
                android:id="@+id/B2"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:button="@null"
                android:layout_marginRight="10dp"
                android:background="@drawable/button_selecltor"
                />
            <RadioButton
                android:id="@+id/B3"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:button="@null"
                android:layout_marginRight="10dp"
                android:background="@drawable/button_selecltor"
                />
            <RadioButton
                android:id="@+id/B4"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:button="@null"
                android:layout_marginRight="10dp"
                android:background="@drawable/button_selecltor"
                />



        </RadioGroup>

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_weight="5">
        <EditText
            android:id="@+id/nr"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:hint="请输入内容"
            android:layout_weight="1"
            />
        <ImageView
            android:id="@+id/pl"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/pinglun"

            android:layout_weight="3"
            />
        <ImageView
            android:id="@+id/zan"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/zanpic"

            android:layout_weight="3"
            />


    </LinearLayout>
</LinearLayout>

2.2后台代码:

package com.example.a05;


import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.Toast;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {
    //定义变量
    //viewPager2的id
    private ViewPager2 mviewPager2;
    //储存碎片集合
    private ArrayList<Fragment> mFragment;
    //适配器
    private MyFragmentPageAdapter myFragmentPageAdapter;

    private ArrayList<Integer> bts;
    private ImageView zan,pinglun;

    private RadioGroup mRadiogroup;
    private boolean zanflag=false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //初始化

        initView();
        initData();
        initiAdapter();
    }
    private void initiAdapter(){
        myFragmentPageAdapter=new MyFragmentPageAdapter(getSupportFragmentManager(),getLifecycle(),mFragment);
        //添加到相应的适配器
        mviewPager2.setAdapter(myFragmentPageAdapter);

    }

    private  void initData(){
        mFragment=new ArrayList<>();
        mFragment.add(new Fragment1());
        mFragment.add(new Fragment2());
        mFragment.add(new Fragment3());
        mFragment.add(new Fragment4());

        bts=new ArrayList<>();
        bts.add(R.id.B1);
        bts.add(R.id.B2);
        bts.add(R.id.B3);
        bts.add(R.id.B4);
        //默认选中
        mRadiogroup.check(R.id.B1);

    }
    private void initView(){
        zan=findViewById(R.id.zan);
        pinglun=findViewById(R.id.pl);
        zan.setOnClickListener(this);
        pinglun.setOnClickListener(this);

        mviewPager2=findViewById(R.id.vp2);
        mviewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                mRadiogroup.check(bts.get(position));
            }


        });
        mRadiogroup=findViewById(R.id.RadioGroup);
        mRadiogroup.setOnCheckedChangeListener(this);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.zan:
                zanflag=!zanflag;
                zan.setSelected(zanflag);
                Toast.makeText(MainActivity.this,"",Toast.LENGTH_LONG).show();
                break;

            case R.id.pl:
                Intent intent = new Intent(MainActivity.this, comment.class);
                startActivity(intent);
                break;
        }
    }



    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {
        mviewPager2.setCurrentItem(bts.indexOf(i));
    }



}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值