我正在构建一个应用程序,该应用程序取决于用户的当前位置。我希望用户能够将其视为文本视图(以移动的字幕(格式看到它。请帮忙缩短它:我需要的是一个文本视图,它将显示用户的实时位置以及用户在特定位置的时间。它应以文本视图格式显示地址和时间。.还包括位置代码。
下面是我的XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
tools:context="com.pyjel.whatsmyusername">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/abeezee"
android:text="what's my username?"
android:textColor="@android:color/background_dark"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.273" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/abeezee"
android:text='"a code would be sent to your phone number, enter code to continue"'
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@android:color/background_dark"
android:textSize="10sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.509"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.715" />
<EditText
android:id="@+id/signupEmailAddress"
android:layout_width="306dp"
android:layout_height="26dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:layout_marginRight="44dp"
android:layout_marginStart="8dp"
android:layout_marginTop="268dp"
android:background="@drawable/edittexttintcolor"
android:backgroundTint="@drawable/edittexttintcolor"
android:fontFamily="@font/abeezee"
android:gravity="center"
android:hint="phone"
android:inputType="phone"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/background_dark"
android:textColorHint="@android:color/background_dark"
android:textSize="14sp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<requestFocus />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/abeezee"
android:text='"to retrieve username, you will have to verify the phone number used during registration"'
android:textAlignment="center"
android:textAllCaps="false"
android:textColor="@android:color/background_dark"
android:textSize="10sp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.358" />
<Button
android:id="@+id/retrieveUsername"
android:layout_width="105dp"
android:layout_height="43dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="432dp"
android:background="@drawable/buttonbackgroundcolor"
android:fontFamily="@font/abeezee"
android:onClick="retrieve"
android:text="retrieve"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.488" />
</android.support.constraint.ConstraintLayout>
及以下是我的Java类
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class whatsmyusername extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_whatsmyusername );
}
}
我希望它看起来像以下图像,也请它有时间在特定位置...我知道我的问题有点冗长,但是请我对此需要帮助。这是图像
使用位置坐标获取地址。即纬度和纵向,Android位置提供了查找API,您可以在此处找到官方文档https://developer.android.com/training/laining/laind/laind/laind/display-address.html