我正在构建一个应用程序,根据用户的当前位置抓取用户的地址。我希望用户能够像textView(移动Marqueee)格式一样看到它。请帮忙 缩短它: 我需要的是一个文本视图,它可以显示用户的实时位置以及用户在特定位置的时间。它应以textview格式显示地址和时间..请同时包含位置代码。
以下是我的XML
import kotlinx.android.synthetic.main.fragment_fragment_first.*
import kotlinx.android.synthetic.main.fragment_fragment_second.*
import kotlinx.android.synthetic.main.fragment_fragment_third.*
...
override fun onNavigationItemSelected(item: MenuItem): Boolean {
// Handle navigation view item clicks here.
objPageAdapter = CustomPageAdapter(supportFragmentManager)
when (item.itemId) {
R.id.nav_fruits -> {
objPageAdapter!!.removeFragments()
objPageAdapter!!.addFragments(FragmentFirst(),getString(R.string.txt_tab_fruits_Element_1))
objPageAdapter!!.addFragments(FragmentSecond(),getString(R.string.txt_tab_fruits_Element_2))
objPageAdapter!!.addFragments(FragmentThird(),getString(R.string.txt_tab_fruits_Element_3))
ViewPagerMain.adapter = objPageAdapter
TabLayoutMain.setupWithViewPager(ViewPagerMain)
this.textViewFragment_1.text = getString(R.string.txt_txtView_fruits_Element_1)
this.textViewFragment_2.text = getString(R.string.txt_txtView_fruits_Element_2)
this.textViewFragment_3.text = getString(R.string.txt_txtView_fruits_Element_3)
...
以下是我的Java类
<?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>
我希望它看起来像下面的图像,并且还请它应该有用户在特定位置的时间...我知道我的问题有点冗长,但我需要帮助。 This is the image
答案 0 :(得分:0)
使用位置坐标获取地址。即纬度和经度,Android Locations提供查找API,你可以在这里找到官方文件https://developer.android.com/training/location/display-address.html