java将当前地址位置显示为文本视图
我正在开发一个应用程序,根据用户的当前位置抓取用户的地址。我希望用户能够看到它像一个文本视图(在移动框)格式。请帮忙 简而言之: 我需要的是一个文本视图,它可以显示用户的实时位置以及用户在特定位置的时间。它应该以文本视图格式显示地址和时间。。请同时附上位置代码
下面是我的XML
<?xml version="1.0" encoding="utf-8"?>
<安卓.support.constraint.ConstraintLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
tools:context="com.pyjel.whatsmyusername">
<TextView
安卓:id="@+id/textView1"
安卓:layout_width="wrap_content"
安卓:layout_height="24dp"
安卓:layout_marginBottom="8dp"
安卓:layout_marginTop="8dp"
安卓:fontFamily="@font/abeezee"
安卓:text="what's my username?"
安卓:textColor="@安卓:color/background_dark"
安卓: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
安卓:id="@+id/textView8"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginBottom="8dp"
安卓:layout_marginTop="8dp"
安卓:fontFamily="@font/abeezee"
安卓:text='"a code would be sent to your phone number, enter code to continue"'
安卓:textAlignment="center"
安卓:textAllCaps="false"
安卓:textColor="@安卓:color/background_dark"
安卓:textSize="10sp"
安卓: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
安卓:id="@+id/signupEmailAddress"
安卓:layout_width="306dp"
安卓:layout_height="26dp"
安卓:layout_centerHorizontal="true"
安卓:layout_centerVertical="true"
安卓:layout_marginEnd="8dp"
安卓:layout_marginRight="44dp"
安卓:layout_marginStart="8dp"
安卓:layout_marginTop="268dp"
安卓:background="@drawable/edittexttintcolor"
安卓:backgroundTint="@drawable/edittexttintcolor"
安卓:fontFamily="@font/abeezee"
安卓:gravity="center"
安卓:hint="phone"
安卓:inputType="phone"
安卓:padding="5dp"
安卓:textAppearance="?安卓:attr/textAppearanceLarge"
安卓:textColor="@安卓:color/background_dark"
安卓:textColorHint="@安卓:color/background_dark"
安卓:textSize="14sp"
安卓:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<requestFocus />
<TextView
安卓:id="@+id/textView9"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_marginBottom="8dp"
安卓:layout_marginTop="8dp"
安卓:fontFamily="@font/abeezee"
安卓:text='"to retrieve username, you will have to verify the phone number used during registration"'
安卓:textAlignment="center"
安卓:textAllCaps="false"
安卓:textColor="@安卓:color/background_dark"
安卓:textSize="10sp"
安卓: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
安卓:id="@+id/retrieveUsername"
安卓:layout_width="105dp"
安卓:layout_height="43dp"
安卓:layout_marginBottom="8dp"
安卓:layout_marginTop="432dp"
安卓:background="@drawable/buttonbackgroundcolor"
安卓:fontFamily="@font/abeezee"
安卓:onClick="retrieve"
安卓:text="retrieve"
安卓:textAllCaps="false"
安卓:textColor="@安卓:color/white"
安卓: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" />
</安卓.support.constraint.ConstraintLayout>
下面是我的Java类
import 安卓.content.Context;
import 安卓.content.Intent;
import 安卓.support.v7.app.AppCompatActivity;
import 安卓.os.Bundle;
import 安卓.telephony.TelephonyManager;
import 安卓.view.View;
import 安卓.widget.EditText;
import 安卓.widget.TextView;
public class whatsmyusername extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_whatsmyusername );
}
}
我希望它看起来像下面的图片,也请它应该有用户在一个特定位置的时间。。。我知道我的问题有点长,但我需要帮助This is the image
# 1 楼答案
使用位置坐标获取地址。i、 e纬度和经度,Android Locations提供了一个查找API,你可以在这里找到官方文档https://developer.android.com/training/location/display-address.html