当前位置:   article > 正文

Android Studio实现跳转功能及聊天功能【教程】

android studio如何实现群聊和私聊的界面跳转

最近在玩Esp32,需要APP,顺带学了下这方面的东西。

8a238275372fb8e7673398d977406da8.png

主要实现功能: 从主  mainActivity  跳转到otherActivity。

新建一个hello工程,添加 otherActivity 和 otherxml.xml

mainActivity内容:

packagecom.example.xiaoyehack.test;importandroid.support.v7.app.AppCompatActivity;importandroid.os.Bundle;importandroid.view.View;importandroid.content.Intent;public class MainActivity extendsAppCompatActivity {

@Overrideprotected voidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}public voidskip(View view){

Intent intent= newIntent();

intent.setClass(MainActivity.this,otherActivity.class);

startActivity(intent);

}

}

activity_main.xml

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"

tools:context=".MainActivity">

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="79dp"

android:layout_marginStart="148dp"

android:layout_marginTop="32dp"

android:layout_marginEnd="148dp"

android:layout_marginBottom="276dp"

android:onClick="skip"

android:text="点击跳转"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toBottomOf="@+id/textView3" />

android:id="@+id/textView3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginStart="122dp"

android:layout_marginTop="105dp"

android:layout_marginEnd="122dp"

android:layout_marginBottom="92dp"

android:text="点击下面按钮实现跳转"

app:layout_constraintBottom_toTopOf="@+id/button"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

otherActivity内容:

package com.example.xiaoyehack.test;

import android.os.Bundle;

import android.support.v7.app.AppCompatActivity;

public class otherActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.otherxml);

}

}

otherxml内容:

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">

赏币地址:

https://download.csdn.net/download/qq_18187161/10882442

无币地址:

链接:https://pan.baidu.com/s/1NWPNbkQxMgkGxpNPX9loLw

提取码:qhnx

提取码复制可见。

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号