저는 안드로이드를 처음 접했고, 어쩌면 내가 끔찍한 잘못을 저지르고 있습니다. 나는 게임에 대한 "생물"클래스의 인스턴스에 대한 세부 정보를 보여주는 특정 활동을 원합니다. 이름, 피해야, 그런 종류의.활동이 제대로 업데이트되지 않습니다.
생물체 데이터가 GUI 개체에 올바르게 표시되도록하는 데 문제가 있습니다. 초기 생성시 (생물체의 이름을 이름 필드에 복사해야하는 경우) 및 손상 표시가 추가 된 경우 (올바른 이미지를 표시하도록 업데이트되지 않는 경우). 이제 문제는 응용 프로그램이로드 및 시작하지만 다음 위젯 중 어느 것도 제대로 업데이트하지 않습니다 것입니다
public class CreatureDetailActivity2 extends Activity
{
Creature creature;
public void addMark(View v)
{
// connected to the button via android:onClick="addMark" in the XML
creature.getTrack().addDamage(DamageType.Normal, 1);
refreshDisplay();
new AlertDialog.Builder(this).setTitle(creature.getName())
.setMessage(creature.getTrack().toString()).show();
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_creature_detail);
creature = new Creature("Example");
refreshDisplay();
}
public void refreshDisplay()
{
final View creatureDetailView = this.getLayoutInflater().inflate(
R.layout.activity_creature_detail, null);
final EditText nameField = (EditText) (creatureDetailView
.findViewById(R.id.textbox_creature_name));
nameField.setText(creature.getName());
final ImageView damageBox0 = (ImageView) (creatureDetailView.findViewById(R.id.damageBox0));
damageBox0.setImageResource(R.drawable.__n);
// in the full program this does the same for 0 through 9, but this is a sample
// also, in the full program, this is a dynamic lookup for the correct pic
// but again, this is just a sample version.
}
}
:
는 여기에 내가 무엇을 내 미니 예입니다. 버튼을 클릭하면 AlertDialog가 표시되고 AlertDialog의 텍스트는 변경되지만 액티비티의 텍스트 필드는 변경되지 않으며 ImageView는 다음과 같이 시작하는 시점에서 언제든지 변경되지 않습니다. 그것을 바꿀 것으로 예상되는 것.
그래서 나는 매우 혼란 스럽습니다. 중요한 항목을 빠뜨리면 프로젝트 설정에 대해 더 게시 할 수 있지만 문제가 무엇인지 확신 할 수 없으므로 내 질문에 무엇을 포함 시킬지 잘 모르겠습니다.