我正在关注本教程并且工作正常。 https://msdn.microsoft.com/en-us/library/system.enum.isdefined(v=vs.110).aspx
但就我而言,我有200张照片。用户将在EditText中写入单词,点击按钮后,分别显示图片。 如何在下面的代码中更改图片来源:
EditText edit = FindViewById<EditText>(Resource.Id.edtName);
button.Click += delegate
{
img.SetImageResource(Resource.Drawable.sample2);
};
其中“sample2”更改为edit.Text。 (为用户写文字...)
答案 0 :(得分:1)
使用方法更改drawable
package com.example.java.beta;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class register extends AppCompatActivity {
EditText ed_username;
TextView btn_register;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ed_username = (EditText)findViewById(R.id.ed_username);
btn_register = (TextView)findViewById(R.id.btn_register);
Typeface unfont = Typeface.createFromAsset(getAssets(),"font_welcome.woff");
ed_username.setTypeface(unfont);
btn_register.setTypeface(unfont);
}
public void reg(View view) {
accounts call = new accounts(register.this);
SQLiteDatabase create = call.getWritableDatabase();
create.execSQL("insert into users values(?,?)",
new String [] {ed_username.getText().toString(),ed_password.getText().toString()});
}
}
}