我希望你一切都好 :) 我正在嘗試通過按鈕從 url 加載 .gif 并能夠在應用會話期間修改 url 并保存。現在我只能運行 gif 如果我把它放在 .load("url") 之間我已經設定了一個 EditText 檔案,所以我可以嘗試呼叫 R.id.EditText,也嘗試使用 getString 但是當我在應用程式中,我將 EditText 替換為它無法識別的其他網址...
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_player)
imageView = findViewById(R.id.viewgif)
greenbtn = findViewById(R.id.gogreenralph)
greenbtn.setOnClickListener{
Glide.with(this)
.load("https://i.makeagif.com/media/4-19-2017/V1hRLP.gif")
.into(imageView)
}
也試過:
enter code hereval greenstring: String name = getString(R.string.urlgreen)
imageView = findViewById(R.id.viewgif)
greenbtn = findViewById(R.id.gogreenralph)
greenbtn.setOnClickListener{
Glide.with(this)
.load(greenstring)
.into(imageView)
}
和 :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_player)
var greentext = findViewById(R.id.greengif) as EditText
imageView = findViewById(R.id.viewgif)
greenbtn = findViewById(R.id.gogreenralph)
greenbtn.setOnClickListener{
Glide.with(this)
.load(greentext)
.into(imageView)
}
活動.xml:
<EditText
android:id="@ id/greengif"
android:text="@string/urlgreen"
android:layout_width="180dp"
android:layout_height="233dp"
android:layout_marginStart="381dp"
android:rotation="90"
android:textColor="@color/black"
android:textColorHint="@color/black"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@ id/gogreenralph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@drawable/greenralphthesquare"
android:rotation="90"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="0dp" />
當然還有 ImageView :
<ImageView
android:id="@ id/viewgif"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rotation="90"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
我真誠地希望有人可以幫助我,我是一個完整的初學者,我真的盡力了):
uj5u.com熱心網友回復:
您應該獲取 EditText 的內容并將其傳遞給load(),如下所示:
var greentext = findViewById(R.id.greengif) as EditText
imageView = findViewById(R.id.viewgif)
greenbtn = findViewById(R.id.gogreenralph)
greenbtn.setOnClickListener{
Glide.with(this)
.load(greentext.text.toString())
.into(imageView)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/440834.html
標籤:安卓 细绳 科特林 android-edittext 机器人滑翔
