我创建了一个简单的应用程序,在我的手机上运行良好的4.2.1。它也可以在我一个朋友的手机上运行冰淇淋三明治。但是当我在另一个朋友的手机(注2)上测试时,它甚至没有安装。我做错了什么?
My XML file:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="120dp"
android:text="TECHNICALnENGLISH -I"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="185dp"
android:text="ENGINEERINGnPHYSICS I"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="250dp"
android:text="ENGINEERINGnCHEMISTRY I"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="315dp"
android:text="COMPTERnPROGRAMMING"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="380dp"
android:text="ENGINEERINGnGRAPHICS"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="445dp"
android:text="COMPUTERnPRGRAMMING LAB"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="510dp"
android:text="ENGINEERINGnPRACTICES LAB"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="575dp"
android:text="PHYSICSnCHEMISTRY LAB"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="65dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="110dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="175dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="240dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="305dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="370dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="435dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="500dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Spinner
android:id="@+id/spinner9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="200dp"
android:layout_marginTop="565dp"
android:entries="@array/Grade"
android:prompt="@string/hello_world"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="55dp" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:gravity="center"
android:text="SEMESTER I - GPA CALCULATOR"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="20dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="75dp"
android:text="MATHEMATICS - I"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView9"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:text="calculate" />
<TextView
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginTop="13dp"
android:editable="false"
android:ems="10"
android:gravity="center"
android:inputType="number"
android:textSize="20sp" />
</RelativeLayout>
</ScrollView>
My Manifest File:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gpa"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.cgpa.MainActivity"
android:label="@string/app_name"
android:theme="@style/NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
My Main_Activity文件:
package com.example.cgpa;
import java.text.DecimalFormat;
import com.example.gpa.R;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.app.Activity;
public class MainActivity extends Activity implements OnClickListener {
TextView e1;
int g1, g2, g3, g4, g5, g6, g7, g8, g9, cr = 0;
int co1 = 0, co2 = 0, co3 = 0, co4 = 0, co5 = 0, co6 = 0, co7 = 0, co8 = 0,
co9 = 0;
String an, ch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Spinner spinner1 = (Spinner) findViewById(R.id.spinner1);
final Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
final Spinner spinner3 = (Spinner) findViewById(R.id.spinner3);
final Spinner spinner4 = (Spinner) findViewById(R.id.spinner4);
final Spinner spinner5 = (Spinner) findViewById(R.id.spinner5);
final Spinner spinner6 = (Spinner) findViewById(R.id.spinner6);
final Spinner spinner7 = (Spinner) findViewById(R.id.spinner7);
final Spinner spinner8 = (Spinner) findViewById(R.id.spinner8);
final Spinner spinner9 = (Spinner) findViewById(R.id.spinner9);
Button b = (Button) findViewById(R.id.button1);
e1 = (TextView) findViewById(R.id.editText1);
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i1 = spinner1.getSelectedItem().toString();
if ("S".equals(i1)) {
g1 = 10;
co1++;
if (co1 == 1)
cr = cr + 4;
} else if ("A".equals(i1)) {
g1 = 9;
co1++;
if (co1 == 1)
cr = cr + 4;
} else if ("B".equals(i1)) {
g1 = 8;
co1++;
if (co1 == 1)
cr = cr + 4;
} else if ("C".equals(i1)) {
g1 = 7;
co1++;
if (co1 == 1)
cr = cr + 4;
} else if ("D".equals(i1)) {
g1 = 6;
co1++;
if (co1 == 1)
cr = cr + 4;
} else if ("E".equals(i1)) {
g1 = 5;
co1++;
if (co1 == 1)
cr = cr + 4;
} else if ("U".equals(i1)) {
if (co1 >=1) {
cr = cr - 4;
co1 = 0;
}
g1 = 0;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner2.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i2 = spinner2.getSelectedItem().toString();
if ("S".equals(i2)) {
g2 = 10;
co2++;
if (co2 == 1)
cr = cr + 4;
} else if ("A".equals(i2)) {
g2 = 9;
co2++;
if (co2 == 1)
cr = cr + 4;
} else if ("B".equals(i2)) {
g2 = 8;
co2++;
if (co2 == 1)
cr = cr + 4;
} else if ("C".equals(i2)) {
g2 = 7;
co2++;
if (co2 == 1)
cr = cr + 4;
} else if ("D".equals(i2)) {
g2 = 6;
co2++;
if (co2 == 1)
cr = cr + 4;
} else if ("E".equals(i2)) {
g2 = 5;
co2++;
if (co2 == 1)
cr = cr + 4;
} else if ("U".equals(i2)) {
if (co2 >= 1) {
cr = cr - 4;
co2 = 0;
}
g2 = 0;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner3.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i3 = spinner3.getSelectedItem().toString();
if ("S".equals(i3)) {
g3 = 10;
co3++;
if (co3 == 1)
cr = cr + 3;
} else if ("A".equals(i3)) {
g3 = 9;
co3++;
if (co3 == 1)
cr = cr + 3;
} else if ("B".equals(i3)) {
g3 = 8;
co3++;
if (co3 == 1)
cr = cr + 3;
} else if ("C".equals(i3)) {
g3 = 7;
co3++;
if (co3 == 1)
cr = cr + 3;
} else if ("D".equals(i3)) {
g3 = 6;
co3++;
if (co3 == 1)
cr = cr + 3;
} else if ("E".equals(i3)) {
g3 = 5;
co3++;
if (co3 == 1)
cr = cr + 3;
} else if ("U".equals(i3)) {
if (co3 >= 1) {
cr = cr - 3;
co3 = 0;
}
g3 = 0;
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner4.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i4 = spinner4.getSelectedItem().toString();
if ("S".equals(i4)) {
g4 = 10;
co4++;
if (co4 == 1)
cr = cr + 3;
} else if ("A".equals(i4)) {
g4 = 9;
co4++;
if (co4 == 1)
cr = cr + 3;
} else if ("B".equals(i4)) {
g4 = 8;
co4++;
if (co4 == 1)
cr = cr + 3;
} else if ("C".equals(i4)) {
g4 = 7;
co4++;
if (co4 == 1)
cr = cr + 3;
} else if ("D".equals(i4)) {
g4 = 6;
co4++;
if (co4 == 1)
cr = cr + 3;
} else if ("E".equals(i4)) {
g4 = 5;
co4++;
if (co4 == 1)
cr = cr + 3;
} else if ("U".equals(i4)) {
g4 = 0;
if (co4 >= 1) {
cr = cr - 3;
co4 = 0;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner5.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i5 = spinner5.getSelectedItem().toString();
if ("S".equals(i5)) {
g5 = 10;
co5++;
if (co5 == 1)
cr = cr + 3;
} else if ("A".equals(i5)) {
g5 = 9;
co5++;
if (co5 == 1)
cr = cr + 3;
} else if ("B".equals(i5)) {
g5 = 8;
co5++;
if (co5 == 1)
cr = cr + 3;
} else if ("C".equals(i5)) {
g5 = 7;
co5++;
if (co5 == 1)
cr = cr + 3;
} else if ("D".equals(i5)) {
g5 = 6;
co5++;
if (co5 == 1)
cr = cr + 3;
} else if ("E".equals(i5)) {
g5 = 5;
co5++;
if (co5 == 1)
cr = cr + 3;
} else if ("U".equals(i5)) {
g5 = 0;
if (co5 >= 1) {
cr = cr - 3;
co5 = 0;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner6.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i6 = spinner6.getSelectedItem().toString();
if ("S".equals(i6)) {
g6 = 10;
co6++;
if (co6 == 1)
cr = cr + 4;
} else if ("A".equals(i6)) {
g6 = 9;
co6++;
if (co6 == 1)
cr = cr + 4;
} else if ("B".equals(i6)) {
g6 = 8;
co6++;
if (co6 == 1)
cr = cr + 4;
} else if ("C".equals(i6)) {
g6 = 7;
co6++;
if (co6 == 1)
cr = cr + 4;
} else if ("D".equals(i6)) {
g6 = 6;
co6++;
if (co6 == 1)
cr = cr + 4;
} else if ("E".equals(i6)) {
g6 = 5;
co6++;
if (co6 == 1)
cr = cr + 4;
} else if ("U".equals(i6)) {
g6 = 0;
if (co6 >= 1) {
cr = cr - 4;
co6 = 0;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner7.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i7 = spinner7.getSelectedItem().toString();
if ("S".equals(i7)) {
g7 = 10;
co7++;
if (co7 == 1)
cr = cr + 2;
} else if ("A".equals(i7)) {
g7 = 9;
co7++;
if (co7 == 1)
cr = cr + 2;
} else if ("B".equals(i7)) {
g7 = 8;
co7++;
if (co7 == 1)
cr = cr + 2;
} else if ("C".equals(i7)) {
g7 = 7;
co7++;
if (co7 == 1)
cr = cr + 2;
} else if ("D".equals(i7)) {
g7 = 6;
co7++;
if (co7 == 1)
cr = cr + 2;
} else if ("E".equals(i7)) {
g7 = 5;
co7++;
if (co7 == 1)
cr = cr + 2;
} else if ("U".equals(i7)) {
g7 = 0;
if (co7 >= 1) {
cr = cr - 2;
co7 = 0;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner8.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i8 = spinner8.getSelectedItem().toString();
if ("S".equals(i8)) {
g8 = 10;
co8++;
if (co8 == 1)
cr = cr + 2;
} else if ("A".equals(i8)) {
g8 = 9;
co8++;
if (co8 == 1)
cr = cr + 2;
} else if ("B".equals(i8)) {
g8 = 8;
co8++;
if (co8 == 1)
cr = cr + 2;
} else if ("C".equals(i8)) {
g8 = 7;
co8++;
if (co8 == 1)
cr = cr + 2;
} else if ("D".equals(i8)) {
g8 = 6;
co8++;
if (co8 == 1)
cr = cr + 2;
} else if ("E".equals(i8)) {
g8 = 5;
co8++;
if (co8 == 1)
cr = cr + 2;
} else if ("U".equals(i8)) {
g8 = 0;
if (co8 >= 1) {
cr = cr - 2;
co8 = 0;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
spinner9.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
String i9 = spinner9.getSelectedItem().toString();
if ("S".equals(i9)) {
g9 = 10;
co9++;
if (co9 == 1)
cr = cr + 1;
} else if ("A".equals(i9)) {
g9 = 9;
co9++;
if (co9 == 1)
cr = cr + 1;
} else if ("B".equals(i9)) {
g9 = 8;
co9++;
if (co9 == 1)
cr = cr + 1;
} else if ("C".equals(i9)) {
g9 = 7;
co9++;
if (co9 == 1)
cr = cr + 1;
} else if ("D".equals(i9)) {
g9 = 6;
co9++;
if (co9 == 1)
cr = cr + 1;
} else if ("E".equals(i9)) {
g9 = 5;
co9++;
if (co9 == 1)
cr = cr + 1;
} else if ("U".equals(i9)) {
g9 = 0;
if (co9 >= 1) {
cr = cr - 1;
co9 = 0;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int a = (g1 * 4 + g2 * 4 + g3 * 3 + g4 * 3 + g5 * 3 + g6 *4
+ g7 * 2 + g8 * 2 + g9 * 1);
double e11 = a / (float) cr;
DecimalFormat df = new DecimalFormat("#.00");
an = df.format(e11);
ch = String.valueOf(an);
e1.setText("Your GPA is " + ch);
}
});
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
我给他发了一个dropbox的链接,他下载了链接页而不是apk