小學四則運算口算練習app---No.6

來源:互聯網
上載者:User

標籤:toast   div   rri   ons   version   vertica   android   extends   info   

今天主要解決按鈕的閃退問題以及答案頁面的設定:

布局activity_result:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/ff"
android:weightSum="1">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".ResultActivity" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="202dp"
android:orientation="vertical" >

<TextView
android:id="@+id/texttitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:textSize="22sp"
android:layout_marginTop="36dp"
android:textColor="#ff5e00"
android:text="你的答案 正確答案 判斷" />

<TextView
android:id="@+id/textresult"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="35dp"
android:textColor="#f9453e4e"
android:text="TextView" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:textSize="12pt"
android:textColor="#ff3c00"
android:text="TextView" />

</LinearLayout>
</ScrollView>

 

(位置問題還是無能為力。。。。)

除此之外加了一些菜單鍵,右上方


resultActivity.class

package com.example.mmmjh.calculator;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

public class resultActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);
TextView text=(TextView)findViewById(R.id.textresult);
TextView text2=(TextView)findViewById(R.id.textView1);
Intent inten=getIntent();
Bundle bundle=inten.getExtras();
int []shu1 = inten.getIntArrayExtra("shu1");//產生的數字
int []shu2 = inten.getIntArrayExtra("shu2");//產生的數字
String []user = inten.getStringArrayExtra("user");//算的結果
String []show = inten.getStringArrayExtra("show");//產生的算式
int []result = inten.getIntArrayExtra("result");//正確的結果
String time=bundle.getString("time");//用時
int score=0;
String select="";
String all=" ";
for(int i=0;i<shu1.length;i++)
{
select="";
String resultstring="";
resultstring=Integer.toString(result[i]);
if(user[i].equals(resultstring))
{
score++;//答對的數目
select+="??";
}
else
select+="??";
all+=""+show[i]+user[i]+" "+result[i]+" "+select+"\n";
text.setText(all);
}
text2.setText("本次一共"+shu1.length+"道題,回答正確"+score+"道!"+time);

}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
menu.add(Menu.NONE, Menu.FIRST + 2, 2, "返回設定頁面").setIcon(android.R.drawable.ic_menu_edit);
menu.add(Menu.NONE, Menu.FIRST + 3, 6, "協助").setIcon(android.R.drawable.ic_menu_help);
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case Menu.FIRST + 2:
Intent intent = new Intent();
intent.setClass(resultActivity.this, activity_calculators.class);//跳轉
startActivity(intent);
break;
case Menu.FIRST + 3:
Toast.makeText(this, "協助菜單被點擊了", Toast.LENGTH_LONG).show();

break;
}
return false;
}
}

 




(按鈕的閃退問題還是沒能解決!)

小學四則運算口算練習app---No.6

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.