当前位置: 编程技术>移动开发
本页文章导读:
▪闹钟程序被封闭,闹钟设置继续使用的处理 闹钟程序被关闭,闹钟设置继续使用的处理
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
{
AlarmManager aMgr = (AlarmManager) cx.getSystemService(Context.ALARM_SERVICE);
PendingIntent pi = PendingIn.........
▪ 4.6 RadioButton与RadioGroup的施用 4.6 RadioButton与RadioGroup的使用
package com.chaowen;
import javax.security.auth.PrivateCredentialPermission;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import a.........
▪ WP7学习心得002-if-else话语练习 WP7学习心得002---if-else语句练习
今天知道了几件事情,由于对C#还是比较生疏的,最近生在恶补
学了几天的WPF才发现WP7并不需要WPF,而是用的是silverlight(银光技术),让我很晕啊,还要C#跟JA.........
[1]闹钟程序被封闭,闹钟设置继续使用的处理
来源: 互联网 发布时间: 2014-02-18
闹钟程序被关闭,闹钟设置继续使用的处理
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
{
AlarmManager aMgr = (AlarmManager) cx.getSystemService(Context.ALARM_SERVICE);
PendingIntent pi = PendingIntent.getBroadcast(cx, 0, new Intent(cx, ScheduleReceiver.class), 0);
aMgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, Thoth.Settings.ALARM_TRIGGER_AT_TIME, Thoth.Settings.ALARM_INTERVAL, pi);
}
[2] 4.6 RadioButton与RadioGroup的施用
来源: 互联网 发布时间: 2014-02-18
4.6 RadioButton与RadioGroup的使用
package com.chaowen;
import javax.security.auth.PrivateCredentialPermission;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
public class Ex04_06_RadioGroup extends Activity {
/** Called when the activity is first created. */
private TextView mTextView;
private RadioGroup radioGroup;
private RadioButton radioButton1,radioButton2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTextView=(TextView)findViewById(R.id.myTextView);
radioButton1=(RadioButton)findViewById(R.id.myRadioButton1);
radioButton2=(RadioButton)findViewById(R.id.myRadioButton2);
radioGroup=(RadioGroup)findViewById(R.id.myRadioGroup);
RadioGroup.OnCheckedChangeListener mChangeRadio=new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(checkedId==radioButton1.getId()){
//把radioButton的内容传到mTextview1
mTextView.setText(radioButton1.getText());
}else if(checkedId==radioButton2.getId()){
//把mRadio2的内容传到mTextView1
mTextView.setText(radioButton2.getText());
}
}
};
//RadioGroup用OnCheckedChangeListener来运行
radioGroup.setOnCheckedChangeListener(mChangeRadio);
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!--第一個TextView -->
<TextView
android:id="@+id/myTextView"
android:layout_width="228px"
android:layout_height="49px"
android:text="@string/str_radio_question1"
android:textSize="30sp"
android:layout_x="37px"
android:layout_y="3px"
/>
<!--建立一個RadioGroup -->
<RadioGroup
android:id="@+id/myRadioGroup"
android:layout_width="137px"
android:layout_height="216px"
android:orientation="vertical"
android:layout_x="3px"
android:layout_y="54px"
>
<!--第一個RadioButton -->
<RadioButton
android:id="@+id/myRadioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tr_radio_op1"
/>
<!--第二個RadioButton -->
<RadioButton
android:id="@+id/myRadioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/tr_radio_op2"
/>
</RadioGroup>
</AbsoluteLayout>
Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Ex04_06_RadioGroup!</string>
<string name="app_name">Ex04_06_RadioGroup</string>
<string name="tr_radio_op1">帥哥</string>
<string name="tr_radio_op2">美女</string>
<string name="str_radio_question1">請問你是?</string>
</resources>
[3] WP7学习心得002-if-else话语练习
来源: 互联网 发布时间: 2014-02-18
WP7学习心得002---if-else语句练习
今天知道了几件事情,由于对C#还是比较生疏的,最近生在恶补
学了几天的WPF才发现WP7并不需要WPF,而是用的是silverlight(银光技术),让我很晕啊,还要C#跟JAVA是比较相似的,这就让我放心很多了,但是银光技术还是陌生的,所以需要从新学习。
tips:
String message = "Hello";
MyTextBox.Text = message + " World";
上面的那句话等同于
MyTextBox.Text = String.Format("{0} World",message);
好,现在开始写程序
1、打开VS2010 express for windows phone,创建一个Application,名字叫做“Test”
2、在可视化设计界面里设计一个小程序,里面有两个TextBlock,一个TextBox,一个Button,如图
3、为这些组件设置响应的属性,注意,将TextBlock的属性中的TextWrapping设置为Wrap,而不是NoWrap,其实设置为Wrap的意思就是里面的文字自动换行的意思
4、点击Button控件,进入代码中,编写代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace Test
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
String valueText = textBox1.Text;
if (valueText == "1")
{
textBlock2.Text = "你赢得了一辆宝马!";
}
else if(valueText == "2")
{
textBlock2.Text = "你捡到了一部手机";
}
else if (valueText == "3")
{
textBlock2.Text = "你得到了100万人民币";
}
else
{
textBlock2.Text = "你失败了,很失败!";
}
}
}
}
5、运行:点击绿色图标或者(Ctrl+F5)
最新技术文章: