0

我正在开发一个安卓应用程序。这是一个考试应用程序。当用户单击答案时,应用程序会$setContentView();在同一活动中更改布局。但它给出了布局错误原因:java.lang.NumberFormatException:无法将'@2131230721'解析为整数

我的布局文件在下面,如果你需要我可以把我的项目 myserver. 我可以粘贴我的活动代码,但这只是基本的setContentView()。我猜我的一个 id 导致了错误,但我找不到它。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:orientation="vertical"
android:weightSum="1" >

<LinearLayout
    android:id="@+id/soruNoIleriVeGeri"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.01"
    android:weightSum="1" >

    <LinearLayout
        android:id="@+id/SoruLayout"
        android:layout_width="fill_parent"
        android:layout_height="60dp"
        android:background="@drawable/question_top_plain"
        android:weightSum="1" >

        <LinearLayout
            android:id="@+id/OncekiSoru"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ImageButton
                android:id="@+id/qIPrevious"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/back_button"
                android:onClick="qIPrevious"
                android:paddingLeft="5dp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="57dp"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/about_question" />
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >

            <ImageButton
                android:id="@+id/ImageButton01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/add_favourite" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/goToQuestion"
                android:layout_width="56dp"
                android:layout_height="wrap_content"
                android:onClick="onshowQuestion"
                android:src="@drawable/show_question" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="50dp"
            android:layout_height="45dp"
            android:layout_weight="0.57" >

            <ImageButton
                android:id="@+id/homeButton"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:background="@drawable/tab_home"
                android:onClick="goHome" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >

            <ImageButton
                android:id="@+id/imageButton1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/next_button"
                android:onClick="qINextQuestion" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/question_top_plain"
    android:weightSum="1" >

    <LinearLayout
        android:id="@+id/resultIconPlain"
        android:layout_width="84dp"
        android:layout_height="fill_parent"
        android:paddingLeft="20dp" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="234dp"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/resultView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1.13"
            android:gravity="center_horizontal"
            android:text="TextView"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#111" />
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="59dp"
    android:background="@drawable/question_top_plain" >

    <LinearLayout
        android:id="@+id/dogruCevap"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.01"
        android:weightSum="1" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >

            <TextView
                android:id="@+id/StatikDogruCevap"
                android:layout_width="126dp"
                android:layout_height="wrap_content"
                android:text="@string/StatikDogruCevap"
                android:textStyle="@style/boldText" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight="0.01" >

            <TextView
                android:id="@+id/dogruCevapView"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:paddingRight="10dp"
                android:text="TextView"
                android:textStyle="@style/rightAnswer" />
        </LinearLayout>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/cevabiniz"
        android:layout_width="fill_parent"
        android:layout_height="54dp"
        android:layout_weight="0.01"
        android:weightSum="1" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >

            <TextView
                android:id="@+id/cevabinizView"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:paddingLeft="10dp"
                android:text="TextView"
                android:textStyle="@style/rightAnswer" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="fill_parent" >

            <TextView
                android:id="@+id/StatikCevap"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/StatikCevap"
                android:textStyle="@style/boldText" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

<ScrollView
    android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="350px"
    android:fillViewport="true" >

    <LinearLayout
        android:id="@+id/dogruCevapAyrinti"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.60"
        android:isScrollContainer="true"
        android:minHeight="400px"
        android:scrollbarAlwaysDrawHorizontalTrack="true"
        android:scrollbars="vertical" >

        <TextView
            android:id="@+id/dogruCevapAyrintiView"
            android:layout_width="fill_parent"
            android:layout_height="324dp"
            android:scrollHorizontally="false"
            android:scrollbarAlwaysDrawHorizontalTrack="true"
            android:scrollbars="vertical"
            android:text="TextView"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#111" >
        </TextView>
    </LinearLayout>
  </ScrollView>

</LinearLayout>

这是错误代码,myActivity 对土耳其变量名表示抱歉

   at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
    at      

       com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4363)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    at dalvik.system.NativeStart.main(Native Method)
        java.lang.reflect.InvocationTargetException
    at android.widget.TextView.<init>(TextView.java:320)
    at java.lang.reflect.Constructor.constructNative(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
    at android.view.LayoutInflater.createView(LayoutInflater.java:500)
    ... 41 more
        java.lang.NumberFormatException: unable to parse '@2131230721' as integer
    at java.lang.Integer.parse(Integer.java:374)
    at java.lang.Integer.parseInt(Integer.java:363)
    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:121)
    at android.content.res.TypedArray.getInt(TypedArray.java:201)
    at android.widget.TextView.<init>(TextView.java:647)



    package com.eandroid.workingSet;

 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;

 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;

 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.message.BasicNameValuePair;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;

 import android.app.Activity;
 import android.app.TabActivity;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.Toast;

     import com.eandroid.entity.Question;

    public class QuestionInterfaceActivity extends Activity {
LinearLayout layoutForA;
LinearLayout layoutForB;
LinearLayout layoutForC;
LinearLayout layoutForD;
LinearLayout layoutForE;
LinearLayout choiceATotalPlain;
LinearLayout choiceBTotalPlain;
LinearLayout choiceCTotalPlain;
LinearLayout choiceDTotalPlain;
LinearLayout choiceETotalPlain;
LinearLayout allTotalPlain;
List<Question> questionList = new ArrayList<Question>();
Node node = null;
NodeList nodeList = null;
NodeList nodeListForTestInfo = null;
InputStream is = null;

private TextView choiceA;
private TextView choiceB;
private TextView choiceC;
private TextView choiceD;
private TextView choiceE;
private TextView questionText;
private TextView soruIdText;
private TextView soruIdEv;
private TextView soruBilgileriView;
private TextView cevabinizView;
private TextView dogruCevapView;
private TextView dogruCevapAyrintiView;
private TextView resultView;
private int currentQuestionIndex;
Question currentQuestion = null;
private String testName = null;
HttpClient httpclient;
HttpPost httppost;
ArrayList<NameValuePair> postParameters;
HttpResponse response;
InputStream contentStream;
private String rightAnswers = "";
private String userAnswers = "";
private String resultOfAnswers = "";
private String userId = "1";
private static String testRelationId;
private LinearLayout resultIconPlain;

private static String willPostUrl = 
     "http://balabanhafriyat.com/SchoolProjectWebSide/postFromPhone/SendDataFromPhone";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        Toast.makeText(QuestionInterfaceActivity.this, "Hoşgeldin  Hacı",
                Toast.LENGTH_SHORT).show();
    }
    settleOrientation();
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        testName = extras.getString("testName");
    }
    try {
        is = getAssets().open(testName);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(new InputSource(is));
        doc.getDocumentElement().normalize();
        nodeList = doc.getElementsByTagName("question");
        nodeListForTestInfo = doc.getElementsByTagName("testInfo");
        Node testNode = nodeListForTestInfo.item(0);
        testRelationId = parseItToStringByName(testNode, "testRelationId");

    } catch (Exception e) {
        e.printStackTrace();
    }
    currentQuestionIndex = 1;
    showQuestion();
}

public void settleOrientation() {
    int setLayout = getResources().getConfiguration().orientation;
    switch (setLayout) {
    case 1:
        setContentView(R.layout.buttontry);
        loadDesign();
        break;
    case 2:
        setContentView(R.layout.buttontry);
        break;
    default:
        break;
    }
}

public void callEvaluationActivity(int optionToSeeQuestion,
        String userAnswer) {

    setContentView(R.layout.evaluation_screen);


    // resultView = (TextView) findViewById(R.id.resultView);

    cevabinizView = (TextView) findViewById(R.id.cevabiniz);
    dogruCevapView = (TextView) findViewById(R.id.rightAnswer);

    dogruCevapAyrintiView = (TextView) 
            findViewById(R.id.dogruCevapAyrintiView);
    // soruBilgileriView.setText(currentQuestion.getShortInfo());

    dogruCevapAyrintiView.setText(currentQuestion.getRightAnswerDetail());
    dogruCevapView.setText(currentQuestion.getRightAnswer());
    if (optionToSeeQuestion == 2) {
        cevabinizView.setText(userAnswer);
        if (currentQuestion.getRightAnswer().equals(userAnswer)) {
            resultView.setTextColor(Color.GREEN);
            resultView.setText("Doğru Cevap");
            resultOfAnswers = resultOfAnswers + "1$";
        } else {
            resultView.setTextColor(Color.RED);
            resultView.setText("Cevap Yanlış !!! ");
            resultOfAnswers = resultOfAnswers + "0$";
        }
        userAnswers = userAnswers + userAnswer + "$";
        rightAnswers = rightAnswers + currentQuestion.getRightAnswer()
                + "$";
    }
}



public void loadDesign() {
    allTotalPlain = (LinearLayout) findViewById(R.id.allTotalPlain);
    allTotalPlain.setBackgroundResource(R.drawable.yellow_button);
    choiceATotalPlain = (LinearLayout) findViewById(R.id.choiceTotalPlain);
    choiceBTotalPlain = (LinearLayout) findViewById(R.id.choiceBTotalPlain);
    choiceCTotalPlain = (LinearLayout) findViewById(R.id.choiceCTotalPlain);
    choiceDTotalPlain = (LinearLayout) findViewById(R.id.choiceDTotalPlain);
    choiceETotalPlain = (LinearLayout) findViewById(R.id.choiceETotalPlain);
    layoutForA = (LinearLayout) findViewById(R.id.abuttonLayout);
    layoutForB = (LinearLayout) findViewById(R.id.bButtonLayout);
    layoutForC = (LinearLayout) findViewById(R.id.cButtonLayout);
    layoutForD = (LinearLayout) findViewById(R.id.dButtonLayout);
    layoutForE = (LinearLayout) findViewById(R.id.ebuttonLayout);
    createButton("A");
    createButton("B");
    createButton("C");
    createButton("D");
    createButton("E");
}

private void showQuestion() {
    questionText = (TextView) findViewById(R.id.soruTextView);
    choiceA = (TextView) findViewById(R.id.choiceA);
    choiceB = (TextView) findViewById(R.id.choiceB);
    choiceC = (TextView) findViewById(R.id.choiceC);
    choiceD = (TextView) findViewById(R.id.choiceD);
    choiceE = (TextView) findViewById(R.id.choiceE);
    currentQuestion = setQuestionFieldById(currentQuestionIndex);
    questionText.setText(currentQuestion.getQuestionText());

    choiceA.setText(currentQuestion.getChoiceA());
    choiceB.setText(currentQuestion.getChoiceB());
    choiceC.setText(currentQuestion.getChoiceC());
    choiceD.setText(currentQuestion.getChoiceD());
    choiceE.setText(currentQuestion.getChoiceE());
    /*
     * consumerAnswer .setOnCheckedChangeListener(new
     * OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup
     * group, int checkedId) { if (choiceA.getId() == checkedId) {
     * approveAnswer(2, "A"); } if (choiceB.getId() == checkedId) {
     * 
     * approveAnswer(2, "B"); } if (choiceC.getId() == checkedId) {
     * 
     * approveAnswer(2, "C"); } if (choiceD.getId() == checkedId) {
     * 
     * approveAnswer(2, "D"); } if (choiceE.getId() == checkedId) {
     * 
     * approveAnswer(2, "E"); } } });
     */
}

private void approveAnswer(int optionToSeeQuestion, final String userChoice) {
    callEvaluationActivity(optionToSeeQuestion, userChoice);
}

// Eger optionToSeeQuestion 1 ise kullanıcının cevap karsılastırılması
// yapılmamalı 2 ise yapılmalı

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == 999) {
        if (data.hasExtra("action")) {
            String aim = data.getExtras().getString("aim");
            Toast.makeText(this, "Ne yapmak istiyorsunuz" + aim,
                    Toast.LENGTH_LONG).show();
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

public void qINextQuestion(View view) {

    if (currentQuestionIndex == nodeList.getLength() - 1) {
        Toast.makeText(QuestionInterfaceActivity.this, "Son Sorudasınız",
                Toast.LENGTH_SHORT).show();
    } else {
        currentQuestionIndex++;
        settleOrientation();
        showQuestion();
    }
}

public void qIPrevious(View view) {
    if (currentQuestionIndex == 1) {
        Toast.makeText(QuestionInterfaceActivity.this, "İlk Sorudasınız",
                Toast.LENGTH_SHORT).show();
    } else {
        currentQuestionIndex--;
        settleOrientation();
        showQuestion();
    }
}

public Question setQuestionFieldById(int questionId) {
    Question q = new Question();
    for (int i = 0; i < nodeList.getLength(); i++) {
        node = nodeList.item(i);

        int idFromXml = Integer.parseInt(parseItToStringByName(node,
                "questionNumber"));
        if (questionId == idFromXml) {
            q.setQuestionId(questionId);
            q.setChoiceA(parseItToStringByName(node, "choiceA"));
            q.setChoiceB(parseItToStringByName(node, "choiceB"));
            q.setChoiceC(parseItToStringByName(node, "choiceC"));
            q.setChoiceD(parseItToStringByName(node, "choiceD"));
            q.setChoiceE(parseItToStringByName(node, "choiceE"));
            q.setQuestionText(parseItToStringByName(node, 
                            "questionText"));
            q.setRightAnswer(parseItToStringByName(node,  
                            "rightAnswer"));
            q.setRightAnswerDetail(parseItToStringByName(node,
                    "answerDetail"));

        }

    }
    return q;
}

public String parseItToStringByName(Node node, String nodeName) {
    Element mainELement = (Element) node;
    NodeList questionList = mainELement.getElementsByTagName(nodeName);
    Element questionElement = (Element) questionList.item(0);
    NodeList question = questionElement.getChildNodes();
    String result = question.item(0).getNodeValue().replaceAll("\n", "")
            .replaceAll("\t", "");
    result.trim();
    return result;
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setContentView(R.layout.landscapequestion);
        showQuestion();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.buttontry);
        showQuestion();
    }
}

@Override
public void onBackPressed() {
    beforeQuitProcess();
    super.onBackPressed();

}

public void beforeQuitProcess() {
    postParameters = new ArrayList<NameValuePair>();
    postParameters.add(new BasicNameValuePair("testId", testRelationId));
    postParameters
            .add(new BasicNameValuePair("rightAnswers", rightAnswers));
    postParameters.add(new BasicNameValuePair("userAnswers", userAnswers));
    postParameters.add(new BasicNameValuePair("userAnswerAndResult",
            resultOfAnswers));
    postParameters.add(new BasicNameValuePair("userId", userId));
    PostDataToServer postDataToServer = new PostDataToServer();
    HttpResponse response = postDataToServer.postData(willPostUrl,
            postParameters);
    contentStream = postDataToServer.parseHttpResponseToStream(response);
    String responseFromServer = postDataToServer
            .convertStreamToString(contentStream);
    if (responseFromServer != null) {
        Toast.makeText(QuestionInterfaceActivity.this, "Kayıt Edildi",
                Toast.LENGTH_SHORT).show();
    }
}



@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    Toast.makeText(QuestionInterfaceActivity.this, "Çıktı Hacı",
            Toast.LENGTH_SHORT).show();
    // Save UI state changes to the savedInstanceState.
    // This bundle will be passed to onCreate if the process is
    // killed and restarted.
    savedInstanceState.putBoolean("MyBoolean", true);
    savedInstanceState.putDouble("myDouble", 1.9);
    savedInstanceState.putInt("MyInt", 1);
    savedInstanceState.putString("MyString", "Welcome back to Android");
    // etc.
    super.onSaveInstanceState(savedInstanceState);
    finish();

}

public void onDestroy() {
    super.onDestroy();
    android.os.Process.killProcess(android.os.Process.myPid());
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    Toast.makeText(QuestionInterfaceActivity.this, "Hoşgeldin  Hacı",
            Toast.LENGTH_SHORT).show();
    super.onRestoreInstanceState(savedInstanceState);
    // Restore UI state from the savedInstanceState.
    // This bundle has also been passed to onCreate.
    boolean myBoolean = savedInstanceState.getBoolean("MyBoolean");
    double myDouble = savedInstanceState.getDouble("myDouble");
    int myInt = savedInstanceState.getInt("MyInt");
    String myString = savedInstanceState.getString("MyString");

}

@Override
protected void onResume() {

    super.onResume();
}

public void onshowAnswer(View v) {
    callEvaluationActivity(1, "A");
}

public void onshowQuestion(View view) {
    setContentView(R.layout.buttontry);
    loadDesign();
    showQuestion();

}

public void goHome(View view) {
    beforeQuitProcess();
    Intent intent = new Intent(QuestionInterfaceActivity.this,
            LoginEvaluation.class);
    intent.putExtra("userId", userId);
    startActivity(intent);
}

public void createButton(final String text) {
    Button button = new Button(this);
    button.setTextColor(Color.parseColor("#000000"));
    button.setBackgroundResource(R.drawable.button_selector);
    button.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            clickMeMyFriend(view, text);
        }
    });
    button.setText(text);
    if (text.equals("A")) {
        layoutForA.addView(button);
    }
    if (text.equals("B")) {
        layoutForB.addView(button);
    }
    if (text.equals("C")) {
        layoutForC.addView(button);
    }
    if (text.equals("D")) {
        layoutForD.addView(button);
    }
    if (text.equals("E")) {
        layoutForE.addView(button);
    }
}

private void clickMeMyFriend(View view, String chooice) {
    if (chooice.equals("A")) {
        approveAnswer(2, "A");
    }
    if (chooice.equals("B")) {
        approveAnswer(2, "B");
    }
    if (chooice.equals("C")) {
        approveAnswer(2, "C");
    }
    if (chooice.equals("D")) {
        approveAnswer(2, "D");
    }
    if (chooice.equals("E")) {
        approveAnswer(2, "E");
    }

}

public void onTotalAClick(View view) {

    switch (view.getId()) {

    case R.id.choiceTotalPlain:
        choiceATotalPlain.setBackgroundResource(R.drawable.black_button);
        approveAnswer(2, "A");
        break;
    case R.id.choiceBTotalPlain:
        choiceBTotalPlain.setBackgroundResource(R.drawable.black_button);
        approveAnswer(2, "B");
        break;
    case R.id.choiceCTotalPlain:
        approveAnswer(2, "C");
        choiceCTotalPlain.setBackgroundResource(R.drawable.black_button);
        break;
    case R.id.choiceDTotalPlain:
        approveAnswer(2, "D");
        choiceDTotalPlain.setBackgroundResource(R.drawable.black_button);
        break;
    case R.id.choiceETotalPlain:
        approveAnswer(2, "E");
        choiceETotalPlain.setBackgroundResource(R.drawable.black_button);
        break;
    default:
        break;
    }

}

    }

感谢所有帮助

4

5 回答 5

2

非常感谢 Barak,Alex Lockwood 和其他人的努力在我的布局中

android:textStyle="@style/boldText" 

在这个语句中,值只能是粗体或正常等。这个语句应该像

style="@style/choiceStyle"

感谢您的帮助。我决定在 00:00 之后不工作

于 2012-06-07T22:28:35.407 回答
1

你是说你试图setContentView在一个活动中多次使用吗?

从我读过的所有内容来看,这是行不通的。

如果您想在不切换活动的情况下更改 UI,则需要使用片段,或者将所需的所有视图放入一个布局中,并仅隐藏/显示活动每个部分的相关视图setVisibility()

于 2012-06-07T14:31:04.303 回答
0

你得到 a 的原因NumberFormatException是因为@2131230721不是整数。这是你应该做的:

  1. 重新做整个 XML 布局。我不是在开玩笑……您发布的布局绝对是一场灾难。对不起,如果那是卑鄙的,但我不能让你继续认为这是制作布局的正确方法:)。

    据我所知,您将每个视图都包装在 aLinearLayout中以实现某种边距/填充效果。这就是android:marginandandroid:padding属性的用途。不要用奇怪的android:layout_weight值使事情变得过于复杂,因为这会使你的应用程序在你的布局膨胀时运行得更慢。如果您发现您的 XML 超过 3 或 4 LinearLayouts,您应该退后一步,看看您是否缺少更简单、更有效的解决方案。嵌套LinearLayouts 也是不受欢迎的,因为在运行时给它们充气是很昂贵的,结果会耗尽你的电池。

  2. 执行Project-->Clean并重新启动 Eclipse。

  3. 发布更多信息。例如,您的整个logcat 输出会很好(不仅仅是一行)。发布您的代码也几乎总是一个好主意。从您提供的少量信息中很难理解问题。请记住,提供尽可能多的信息对您是有益的,因为我们拥有的信息越多,我们就越有可能帮助回答您的问题。您还应该向我们提供行号和/或指出错误发生在哪些行上。

哦,是的,欢迎来到 StackOverflow ......:P

于 2012-06-07T14:11:02.237 回答
0

重量是否可能导致问题?我以前从未将权重用作小数,我认为它们必须是实数,我的意思是像 1 或 2 等。楼层数。只是一个想法

从我可以看出它与数字和文本视图有关,这可能是文本视图的颜色、重量、ID 或样式。

style/boldText 和 style/rightAnswer 中有什么?

于 2012-06-07T14:12:55.183 回答
-1

您的布局文件确实以 a 开头LinearLayout并定义了 a xmlns:android="http://schemas.android.com/apk/res/android",但您最终得到了一个结束<ScrollView>标签?有什么遗漏吗?另外,javaCode 会很棒!

顺便说一句:您是否尝试使用 Project->Clean 在 Eclipse 中“清理”您的项目?这会重置 R 文件并且通常会有所帮助!

于 2012-06-07T13:58:44.583 回答