"andy emulator"を使用してアンドロイドスタジオでデバッガを実行していましたが、アンドロイドスタジオのアンドロイドエミュレータとほぼ同じです私はそれを受け取ったランタイムエラー 11月13日:56:57.796 8967-8976 /? I/AndroidRuntime:注:スレッド 'Binder_1'の添付が失敗しました 11-01 13:56:58.530 8997-9006 /? I/AndroidRuntime:注:スレッド 'Binder_2'の添付が失敗しました それを修正してください。 これが助けになるかどうか分かりませんが、ブルースタックスでアプリを実行すると画面がフリーズし、ボタンはクリックできなくなります。クリックすると、フリーズしてもクラッシュしません。修正する方法:スレッド 'Binder_1'の添付が失敗しました 'Binder_2'スレッドの添付が失敗しました
は、これは場合に役立ちます私のコードです:
package com.example.android.quizgenerator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import static android.R.attr.x;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void Print(View view)
{
//get the text
EditText nameField = (EditText) findViewById(R.id.fill_here);
Editable text_ar = nameField.getText();
String s = text_ar.toString(); //this is the string that is going to be cut
String s2 = ""; //this is the final string
String MyText = ""; //this is the stringwhere we accumulate characters
String x, x1, x2, x3, x4 = "";
//the counter i, the check if !=a,an,the variable t
int n = 0;
int i = 0;
int t = 0;
//Edit the text
//add the word the translation of X is
while (!(s.equals(""))) {
//only assign this value if the charAt(i) exists
if (s.length() != 0)
x = s.charAt(i) + "";
else
x = "";
if (s.length() > 1) {
x1 = s.charAt(i + 1) + "";
} else
x1 = "";
if (s.length() > 2) {
x2 = s.charAt(i + 2) + "";
} else
x2 = "";
if (s.length() > 3) {
x3 = s.charAt(i + 3) + "";
} else
x3 = "";
if (s.length() > 4) {
x4 = s.charAt(i + 4) + "";
} else
x4 = "";
MyText = MyText + s.charAt(i);
//we should have space the space to enter here
if (x.equals(" ") && x1.equals("t") && x2.equals("h") && x3.equals("e") && x4.equals(" ")) {
//get Mytext and update s
s = s.replace("the ", ""); //deletes 'the ' from s
if (s.indexOf(" ") != -1) {
n = s.indexOf(" "); //index of the end of MyText
MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
//to determine the end of MyText: no space no more words
} else {
MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
// which means it is the end of the sentence: no space no more words
}
s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
MyText = "the translation of the " + MyText + " is"; //added the sentence in the beginning
s2 = s2 + "/n" + MyText; //accumulated all the words in a text
t++;
MyText = "";
//delete the string space the space
}
//we should have space an space to enter here
if (x.equals(" ") && x1.equals("a") && x2.equals("n") && x3.equals(" ")) {
//get Mytext and update s
s = s.replace("an ", ""); //deletes 'the ' from s
if (s.indexOf(" ") != -1) {
n = s.indexOf(" "); //index of the end of MyText
MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
//to determine the end of MyText: no space no more words
} else {
MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
// which means it is the end of the sentence: no space no more words
}
s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
MyText = "the translation of an " + MyText + " is"; //added the sentence in the beginning
s2 = s2 + "/n" + MyText; //accumulated all the words in a text
t++;
MyText = "";
}
//we should have space a space to enter here
if (x.equals(" ") && x1.equals("a") && x2.equals(" ")) {
//get Mytext and update s
s = s.replace("a ", ""); //deletes 'the ' from s
if (s.indexOf(" ") != -1) {
n = s.indexOf(" "); //index of the end of MyText
MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
//to determine the end of MyText: no space no more words
} else {
MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
// which means it is the end of the sentence: no space no more words
}
s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
MyText = "the translation of a " + MyText + " is"; //added the sentence in the beginning
s2 = s2 + "/n" + MyText; //accumulated all the words in a text
t++;
MyText = "";
}
//we should have space anyletter!=the,a,an
if (x.equals(" ") && (t == 0)) //this is a word
{
//get Mytext and update s
s = s.replace(" ", ""); //deletes 'the ' from s
if (s.indexOf(" ") != -1) {
n = s.indexOf(" "); //index of the end of MyText
MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
//to determine the end of MyText: no space no more words
} else {
MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
// which means it is the end of the sentence: no space no more words
}
s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
MyText = "the translation of " + MyText + " is"; //added the sentence in the beginning
s2 = s2 + "/n" + MyText; //accumulated all the words in a text
MyText = "";
}
}
//Print the new text
TextView y = (TextView) findViewById(R.id.print_here);
y.setText(s2);
}
}
私は、この第二の問題を発見し、この問題は解決しようとしたとき: はなぜAndroidアプリがフリーズしますか?
私は 私のアプリで無限のループを持っていると思われる問題を見つけたアンドロイドのアプリケーションの反応は凍結です。
編集すると、完全なスタックトレースが含まれ、コードブロックでフォーマットされ、読みやすくなります。 – codeMagic