• JAVA日报


    从零开始的体温app开发(ThirdActivity)

    package com.example.myapplication;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.AbsListView;
    import android.widget.AdapterView;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ListView;
    import android.widget.Toast;

    import androidx.annotation.Nullable;
    import androidx.appcompat.app.AppCompatActivity;

    import java.util.List;

    import adapter.UserListAdapter;
    import adapter.UserListAdapter2;
    import bean.User;
    import bean.User2;
    import dao.UserDao;
    import dao.UserDao2;

    public class ThirdActivity extends AppCompatActivity implements AdapterView.OnItemClickListener, AbsListView.OnScrollListener {
    private ListView mUserList;
    private UserDao2 userDao=null;
    private List<User2> userList=null;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_third);
    mUserList=findViewById(R.id.user_list2);
    InitData();
    mUserList.setOnItemClickListener(this);
    mUserList.setOnScrollListener(this);
    }
    private void InitData(){
    userDao=UserDao2.getInstance(getApplicationContext());
    userList=userDao.findAll();
    UserListAdapter2 adapter=new UserListAdapter2(getApplicationContext(),userList);
    mUserList.setAdapter(adapter);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Intent intent = new Intent();
    Log.e("position",""+position);
    Toast.makeText(getApplicationContext(), "切换成功", Toast.LENGTH_SHORT).show();
    intent.putExtra("message",position);
    intent.setClass(getApplicationContext(), MainActivity.class);
    startActivity(intent);
    finish();
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

    }
    }
  • 相关阅读:
    url 编码与解码
    调硬件开门
    JsBridge 开灯关灯
    滚动条样式
    uni-app 组件传值及插槽
    Eapp 调接口及跳转
    uni-app 的基础格式
    Eapp 几个弹框
    flexible 移动端适配
    mongodb恢复备份
  • 原文地址:https://www.cnblogs.com/mumulailai/p/14909346.html
Copyright © 2020-2023  润新知