친구 밴드 용으로 응용 프로그램을 만들고 parse라는 클라우드 저장소 API를 사용하고 있습니다. 클라우드에서 문자열을 가져 와서 편집 텍스트에 표시하려고합니다. 생각은 텍스트를 원하는대로 만들고 데이터베이스에 업로드하는 것입니다. 나는 그런 일을 할 수는 있지만, 텍스트를 바꿀 때마다 폰을 수평으로 뒤집은 다음 수직으로 다시 내 편집을 제거합니다. 또한 터치가 특정 레이아웃에서 작동하지 않는 것처럼 보입니다. TabHost 있고 전환 탭을 잘 작동하지만 단추를 클릭 할 때마다 나는 아무것도 얻지 않으며 EditText 커서를 이동할 수 있습니다. 내 버튼에 대한 내 onClick 메서드 내부에 중단 점 및 토스트를 배치했지만 아무 것도 해고되지 않습니다. 나는 무슨 일이 일어나고 있는지 전혀 모른다. 도와주세요!EditText 및 Button이 TabHost 내부의 터치 입력에 응답하지 않습니다.
자바
package com.example.undaunted.admin;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.Toast;
import com.parse.GetCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseFile;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.SaveCallback;
public class UndauntedAdminMain extends Activity {
TabHost tabHost;
Button saveWelcomeText;
EditText welcomeText;
ParseFile file;
ParseObject welcomeTextObject;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.undaunted_main);
welcomeText = (EditText) findViewById(R.id.editText1);
Parse.initialize(this, "REMOVED",
"REMOVED");
initialize();
}
public void initialize() {
tabHost = (TabHost) findViewById(R.id.tabHost);
tabHost.setup();
TabSpec spec = tabHost.newTabSpec("Welcome");
spec.setContent(R.id.welcomeTab);
spec.setIndicator("Welcome");
tabHost.addTab(spec);
TabSpec spec3 = tabHost.newTabSpec("Biographies")
.setContent(R.id.biographyTab).setIndicator("Biographies");
tabHost.addTab(spec3);
// tabHost.newTabSpec("Biographies").setIndicator("Biographies").setContent();
TabSpec spec2 = tabHost.newTabSpec("Gallery");
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.galleryTab);
relativeLayout.setBackgroundColor(Color.BLACK);
spec2.setContent(R.id.galleryTab);
spec2.setIndicator("Gallery");
tabHost.addTab(spec2);
ParseQuery query2;
query2 = new ParseQuery("Welcome");
query2.getInBackground("fdZL8G4PIk", new GetCallback() {
@Override
public void done(ParseObject arg0, ParseException arg1) {
// TODO Auto-generated method stub
if (arg1 == null) {
// welcomeTextObject = arg0;
// welcomeText.setText(welcomeTextObject.getString(
// "WelcomeText").toString());
} else {
welcomeText.setText("Failed to load data");
}
}
});
saveWelcomeText = (Button) findViewById(R.id.saveWelcomeText);
saveWelcomeText.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
welcomeTextObject.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException arg0) {
// TODO Auto-generated method stub
welcomeTextObject.put("WelcomeText",
welcomeText.getText());
welcomeTextObject.saveInBackground();
Toast.makeText(getApplicationContext(), "Data sent",
Toast.LENGTH_SHORT).show();
}
});
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_undaunted_admin_main, menu);
return true;
}
}
XML
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tabHost" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TabWidget
android:id="@+android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/welcomeTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:id="@+id/saveWelcomeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Save" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
<RelativeLayout
android:id="@+id/galleryTab"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RelativeLayout>
<RelativeLayout
android:id="@+id/biographyTab"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView
android:id="@+id/memberList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@+id/biographyTab"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/showDatesTab"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/showDateList"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/showDatesTab">
</ListView>
</RelativeLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
추가적인 세부 사항은, 내가 구문 분석이라는 클라우드 스토리지 라이브러리를 사용하고 있습니다. 여기있는 사람이 익숙한 지 아니면 방해가 될 수 있는지 모르겠지만 도움을 주시면 감사하겠습니다. 감사!
'onCreate()'의 끝에서 뷰를 무효화하려고하면 비슷한 문제가 발생하고 뷰를 무효화하여 도움이되었습니다. –
Nope. 그것은 작동하지 않았다. –