下载地址: http://pan.baidu.com/share/link?shareid=383627&uk=201606611
有Android 手机的可以装一下运行测试看看,谢谢啊!
本人是新手有任何建议、意见、需要代码的可与我本人联系 :QQ交流群:72133568, 27236303,74965947, 16592133, 204725117, 204724518
Activity1.cs 代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
using
System;
using
Android.App;
using
Android.Content;
using
Android.Runtime;
using
Android.Views;
using
Android.Widget;
using
Android.OS;
using
Android.Webkit;
namespace
hz.android.test
{
[Activity (Label =
"hz.android.test"
, MainLauncher =
true
)]
public
class
Activity1 : Activity
{
int
count = 1;
protected
override
void
OnCreate (Bundle bundle)
{
base
.OnCreate (bundle);
SetContentView (Resource.Layout.Main);
Button button = FindViewById<Button> (Resource.Id.myButton);
WebView webView = FindViewById<WebView> (Resource.Id.webView1);
button.Click +=
delegate
{
button.Text =
string
.Format (
"{0} clicks!"
, count++);
webView.LoadUrl(
"http://blog.csdn.net/tengyunjiawu_com/article/details/8565766"
);
};
}
}
}
|
界面设计是可视化的,所见即所得的,比 netneans 和 eclipse 强多了,还有很多各种各样的控件!
netneans 和 eclipse 界面都要自己写 axml文件,这个能拖拉好之后自动生成:
layout/Main.axml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<LinearLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
>
<Button
android:id=
"@+id/myButton"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:text=
"@string/hello"
/>
<WebView
android:layout_width=
"fill_parent"
android:layout_height=
"220.7dp"
android:id=
"@+id/webView1"
android:layout_marginBottom=
"50.0dp"
/>
<EditText
android:inputType=
"textEmailAddress"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/editText1"
android:text=
"bwsyq@bwsyq.com QQ:99923309"
android:linksClickable=
"true"
/>
<DatePicker
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/datePicker1"
/>
<CheckedTextView
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/checkedTextView1"
/>
</LinearLayout>
|
Resource.designer.cs 这个相当于 netbeans 或 java 开发 Android时自动生成的
r.java 类代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.239
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace
hz.android.test
{
public
partial
class
Resource
{
public
partial
class
Attribute
{
private
Attribute()
{
}
}
public
partial
class
Drawable
{
// aapt resource value: 0x7f020000
public
const
int
Icon = 2130837504;
// aapt resource value: 0x7f020001
public
const
int
lbs = 2130837505;
private
Drawable()
{
}
}
public
partial
class
Id
{
// aapt resource value: 0x7f050004
public
const
int
checkedTextView1 = 2131034116;
// aapt resource value: 0x7f050003
public
const
int
datePicker1 = 2131034115;
// aapt resource value: 0x7f050002
public
const
int
editText1 = 2131034114;
// aapt resource value: 0x7f050000
public
const
int
myButton = 2131034112;
// aapt resource value: 0x7f050001
public
const
int
webView1 = 2131034113;
private
Id()
{
}
}
public
partial
class
Layout
{
// aapt resource value: 0x7f030000
public
const
int
Main = 2130903040;
private
Layout()
{
}
}
public
partial
class
String
{
// aapt resource value: 0x7f040001
public
const
int
app_name = 2130968577;
// aapt resource value: 0x7f040000
public
const
int
hello = 2130968576;
private
String()
{
}
}
}
}
|
调试的时候打开 ADV(android 模拟器) 在里面你自己添加一个机器的型号,设置好分辨率,内存大小,SD卡,启动之后,就可以调试了!
调试生成的代码是不能发布到真实的机器上的,因为 android 实际程序在真实机器中运行的时候会进行验证,这个在 netbeans 或 eclipse 里面叫 key.store
所以发布的时候,要用 netbeans 或 eclipse 里面一个叫 keytools的工具,生成一个 key.store的文件
使用格式如下:
D:\Progra~1\Java\jdk1.7.0_11\jre\bin\keytool -genkey -v -keystore xxx-release-key.keystore -alias xxxkeystore -keyalg RSA -keysize 2048 -validity 20000
您的名字与姓氏是什么?
[Unknown]: huangzhi
您的组织单位名称是什么?
[Unknown]: bwsyq co.ltd
您的组织名称是什么?
[Unknown]: bwsyq java develop group
您所在的城市或区域名称是什么?
[Unknown]: hang zhou
您所在的省/市/自治区名称是什么?
[Unknown]: hang zhou
该单位的双字母国家/地区代码是什么?
[Unknown]: 86
CN=huangzhi, OU=bwsyq co.ltd, O=bwsyq java develop group, L=hang zhou, ST=hang z
hou, C=86是否正确?
这样之后或要求你输入密码,这时候就会产生一个 xxx-release-key.keystore 的验证密码文件 别名叫: xxxkeystore
不论是 vs2010 还是 netbeans 还是 eclipse 在release的时候都会要求你输入密码,密码验证通过之后就会生成真正的发布安装文件 xxx.APK ,这个就是可以在真实机器上安装运行的 APP了!
例如:http://pan.baidu.com/share/link?shareid=383627&uk=201606611
这时后还不要高兴,这样编译的程序还只能运行一般的 APP ,如果要使用google 地图API ,你还要从 key.store中取出 MD5 密码
keytool -list -v -alias xxxkeystore -keystore xxx-release-key.keystore
通过这个 keytools的命令去取
然后到 http://www.google.com/glm/mmap google 地图网站获取一个根据 MD5生成的 地图 key
才能在你发布的程序中使用 google 地图 API
当然了,还有很多,比如如何注册,使用 admob 如何在你的应用中增加google 移动广告赚钱,等等,有兴趣的可以加入我们的QQ群一起探讨交流!
本人也是新手有任何建议、意见、需要代码的可与我本人联系 :QQ交流群:72133568, 27236303,74965947, 16592133, 204725117, 204724518