在我的第一个应用程序上计算从Youtube视频中学习的2个值时出现错误消息



我观看和学习的youtube视频位于以下链接:-

 Title is How to make an android app NO PROGRAMMING SKILLS NEEDED pt 1,2,3
 1.http://www.youtube.com/watch?v=Be-YnLcPEdA , http://www.youtube.com/watch?v=Rt0wX3I1Wrg , http://www.youtube.com/watch?v=mkhRCWfTD4A.

我是一名三年级的文凭学生。我之前没有任何编程和应用程序创建方面的知识。我需要为我最后一年的项目开发应用程序。有人请帮帮我。我已经下载了android sdk捆绑包,并试图按照youtube视频完成所有操作。

我有3条错误消息,如下所示。:-

syntax error on token"(";expected.MainActivity.java .line28.type:java problem 
syntax error on token")";expected.MainActivity.java .line28.type:java problem 
Void is an invalid type for the variableCalculate.MainActivity.java.line28.type:java problem 

main activity.java的代码如下:-

     import android.support.v7.app.ActionBarActivity;
     import android.support.v7.app.ActionBar;
     import android.support.v4.app.Fragment;
     import android.os.Bundle;
     import android.view.LayoutInflater;
     import android.view.Menu;
     import android.view.MenuItem;
     import android.view.View;
     import android.view.ViewGroup;
     import android.widget.EditText;
     import android.widget.TextView;
     import android.os.Build; 
     public class MainActivity extends ActionBarActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        } {
        public void Calculate( View v) {
            EditText num1text=(EditText)findViewById(R.id.num1text);
            EditText num2text=(EditText)findViewById(R.id.num2text);
            Integer num1=Integer.parseInt(num1text.getText().toString()) ,num2=Integer.parseInt(num2text.getText().toString());
            Integer ans=num1+num2;
            TextView answer =(TextView)findViewById(R.id.answertxt);

            answer.setText("answer :"+ans.toString());
        }
    }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {
        public PlaceholderFragment() {
        }
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }
}

Fragment main.xml的代码如下:-

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/num1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/num1" />
    <EditText
        android:id="@+id/num1text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberDecimal" />
    <TextView
        android:id="@+id/num2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/num2" />
    <EditText
        android:id="@+id/num2text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="numberDecimal" />
    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/calc"
        android:onClick="Calculate" />
    <TextView
        android:id="@+id/answertxt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/ans" />
</LinearLayout>

codes for activity_main.xml as below:-
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.test.MainActivity"
tools:ignore="MergeRootFrame" />

我需要学习如何制作应用程序,因为我需要为我的项目做。在真实的项目中,智能手机Android KITKAT应该能够使用来自RFduino的蓝牙低能耗(BLE(和来自RFdui诺的BLE中的广告功能接收数据,并将数据发送回RFduino以完成一些任务。我的电子邮件地址是yokesmohan@gmail.com,s10135557@connect.np.edu.sg.Someone请帮帮我。

 if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    } { 

在上面的行中,有一个额外的开放大括号({(。尝试删除它。

相关内容

最新更新