我是第一次开发移动应用
环境:Eclipse Kepler,Java 1.7后端:AWS RDS,数据库类型:MySQL
首先,我创建了一个活动,如下所示,我首先希望它显示" Hello World"在主屏幕上。
对于ref,如果nyone知道在编写代码时是否犯了错误,我会显示出来:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazon.demo2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="20" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/hello_world" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
MainActivity.java:
package com.amazon.demo2;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.*;
public class MainActivity extends ActionBarActivity {
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 boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
}
}
fragment_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="com.amazon.demo2.MainActivity$PlaceholderFragment" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
activity_main.xml:
<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.amazon.demo2.MainActivity"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="134dp"
android:layout_height="36dp"
android:text="@string/hello_world" />
</FrameLayout>
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello_world">Hello world!</string>
<string name="title_activity_main">Welcome Dear Customer</string>
<string name="hey">Hey</string>
</resources>
现在我正在做的是:运行配置 - &gt; Android应用程序 - &gt; Android - &gt;项目[设置要运行的项目] - &gt;启动操作 - &gt;启动 - &gt; com.amazon.demo2.MainActivity - &gt;申请 - &gt;运行
现在它给了我一个错误:
[2014-08-18 14:42:13 - ShopSystem-Android2] ------------------------------
[2014-08-18 14:42:13 - ShopSystem-Android2] Android Launch!
[2014-08-18 14:42:13 - ShopSystem-Android2] adb is running normally.
[2014-08-18 14:42:13 - ShopSystem-Android2] Performing com.amazon.demo2.MainActivity activity launch
[2014-08-18 14:42:14 - ShopSystem-Android2] Automatic Target Mode: Preferred AVD 'standard' is not available. Launching new emulator.
[2014-08-18 14:42:14 - ShopSystem-Android2] Launching a new emulator with Virtual Device 'standard'
[2014-08-18 14:43:04 - Emulator] emulator: warning: opening audio input failed
[2014-08-18 14:43:04 - Emulator]
[2014-08-18 14:43:05 - ShopSystem-Android2] New emulator found: emulator-5554
[2014-08-18 14:43:05 - ShopSystem-Android2] Waiting for HOME ('android.process.acore') to be launched...
[2014-08-18 14:44:33 - ShopSystem-Android2] emulator-5554 disconnected! Cancelling 'com.amazon.demo2.MainActivity activity launch'!
基本上,我想要的是创建一个允许用户查看产品和在线并下订单的应用程序。但是我上面已经搞砸了。请帮忙。谢谢