|
2016年11月29日
http://blog.csdn.net/code__code/article/details/53885510
1. 使用Spring Security管理用戶身份認證、登錄退出
2. 用戶密碼加密及驗證
3. 采用數據庫的方式實現Spring Security的remember-me功能
4. 獲取登錄用戶信息。
5.使用Spring Security管理url和權限
摘要: // 自定義登錄頁面 http.csrf().disable().formLogin().loginPage("/login") //指定登錄頁的路徑&n... 閱讀全文
<bean id="jobDetail7"class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<propertyname="targetObject" ref="billingBillTask"></property>
<propertyname="targetMethod" value="executeInternal" />
<propertyname="concurrent" value="false" />
</bean>
<beanid="billingBillTask"class="com.dangdang.tms.job.schedule.bms.BillingBillTask"/>
<beanid="cronTriggerBean7" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<propertyname="jobDetail" ref="jobDetail7"></property>
<propertyname="cronExpression" value="0/5 * * * * ?"></property>
</bean>
參考 http://blog.csdn.net/lkforce/article/details/51841890
為了解決一些比較費時且不是很緊要的任務,將此任務轉為異步任務處理,提高前端操作體驗。
spring 中 自帶注解 @Async.
配置如下
applicationContext.xml 中 增加 task的引用
如上配置之后,只需要在 需要進行異步調用的方法前面增加 注解就可以了。
@Async
public void updateOrderBillItemPQty(String deptId, String orderNo, Integer orderItemSid, Double pQty) {
注:需要注意,同一個對象里面方法調用,不會作為異步方法執行。
在對 TextView 或者 EditText 進行賦值時,調用setText()方法,一定要注意,使用String類型,不要使用int 或者long,否則 會出現找不到資源的異常。系統自動會將int作為一個資源ID,然后去R 里面找,結果找不到。
摘要: http://blog.csdn.net/meng425841867/article/details/8523730
在按鍵單擊事件中添加創建對話框并設置相關屬性。
[java] view plain copy
dialogButton=(Button)findViewBy... 閱讀全文
摘要: http://daoshud1.iteye.com/blog/1874241
本文講實現一個自定義列表的Android程序,程序將實現一個使用自定義的適配器(Adapter)綁定 數據,通過contextView.setTag綁定數據有按鈕的ListView。 系統顯示列表(ListView)時,首先會實例化一個適配器,本文將實例化一個自定義的適配器。實現 自定義適... 閱讀全文
摘要: http://blog.csdn.net/x605940745/article/details/11981049
SimpleAdapter的參數說明 第一個參數 表示訪問整個android應用程序接口,基本上所有的組件都需要 第二個參數表示生成一個Map(String ,Object)列表選項 第三個參數表示界面布局的id 表示該文件作為列表項的組件&... 閱讀全文
首先是布局文件,這里需要兩個布局文件,一個是放置列表控件的Activity對應的布局文件 main.xml,另一個是ListView中每一行信息顯示所對應的布局 list_item.xml 這一步需要注意的問題是ListView 控件的id要使用Android系統內置的 android:id="@android:id/list" main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dip"/>
</LinearLayout>
 list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<TextView
android:id="@+id/user_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView
android:id="@+id/user_id"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</LinearLayout>
 然后就設置MainActivity中的代碼了:基本思想就是先將數據添加到ArrayList中,然后在設置SimpleAdapter適配器完成設置,入下:

package com.example.android_newlistview;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.view.Menu;
import android.widget.SimpleAdapter;
 public class MainActivity extends ListActivity {
 String[] from= {"name","id"}; //這里是ListView顯示內容每一列的列名
 int[] to= {R.id.user_name,R.id.user_id}; //這里是ListView顯示每一列對應的list_item中控件的id

 String[] userName= {"zhangsan","lisi","wangwu","zhaoliu"}; //這里第一列所要顯示的人名
 String[] userId= {"1001","1002","1003","1004"}; //這里是人名對應的ID

ArrayList<HashMap<String,String>> list=null;
HashMap<String,String> map=null;
@Override
 protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main); //為MainActivity設置主布局
//創建ArrayList對象;
list=new ArrayList<HashMap<String,String>>();
//將數據存放進ArrayList對象中,數據安排的結構是,ListView的一行數據對應一個HashMap對象,
//HashMap對象,以列名作為鍵,以該列的值作為Value,將各列信息添加進map中,然后再把每一列對應
//的map對象添加到ArrayList中

 for(int i=0; i<4; i++) {
map=new HashMap<String,String>(); //為避免產生空指針異常,有幾列就創建幾個map對象
map.put("id", userId[i]);
map.put("name", userName[i]);
list.add(map);
}

//創建一個SimpleAdapter對象
SimpleAdapter adapter=new SimpleAdapter(this,list,R.layout.list_item,from,to);
//調用ListActivity的setListAdapter方法,為ListView設置適配器
setListAdapter(adapter);
}
}另外對點擊某一行作出響應的方法是覆寫onListItemClick方法,根據返回的position(從0開始):
@Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
}
單數據{'singer':{'id':01,'name':'tom','gender':'男'}}
多個數據{"singers":[
{'id':02,'name':'tom','gender':'男'},
{'id':03,'name':'jerry,'gender':'男'},
{'id':04,'name':'jim,'gender':'男'},
{'id':05,'name':'lily,'gender':'女'}]} // 普通Json數據解析
 private void parseJson(String strResult) {
 try {
JSONObject jsonObj = new JSONObject(strResult).getJSONObject("singer");
int id = jsonObj.getInt("id");
String name = jsonObj.getString("name");
String gender = jsonObj.getString("gender");
tvJson.setText("ID號"+id + ", 姓名:" + name + ",性別:" + gender);
 } catch (JSONException e) {
System.out.println("Json parse error");
e.printStackTrace();
}
}
//解析多個數據的Json
 private void parseJsonMulti(String strResult) {
 try {
JSONArray jsonObjs = new JSONObject(strResult).getJSONArray("singers");
String s = "";
 for(int i = 0; i < jsonObjs.length() ; i++){
JSONObject jsonObj = ((JSONObject)jsonObjs.opt(i)).getJSONObject("singer");
int id = jsonObj.getInt("id");
String name = jsonObj.getString("name");
String gender = jsonObj.getString("gender");
s += "ID號"+id + ", 姓名:" + name + ",性別:" + gender+ "\n" ;
}
tvJson.setText(s);
 } catch (JSONException e) {
System.out.println("Jsons parse error !");
e.printStackTrace();
}
}
-
- Button Btn1 = (Button)findViewById(R.id.button1);
- Btn1.setOnClickListener(new Button.OnClickListener(){
- public void onClick(View v) {
- String strTmp = "點擊Button01";
- Ev1.setText(strTmp);
- }
-
- });
-
- public void Btn3OnClick(View view){
- String strTmp="點擊Button03";
- Ev1.setText(strTmp);
-
- }
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button3"
- android:onClick="Btn3OnClick"/>
第三種方式 activity 實現 單擊監聽接口
public class TestButtonActivity extends Activity implements OnClickListener {
Button btn1, btn2;
Toast tst;
@Override
protected void onCreate(Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.activity_test_button);
btn1 = (Button) findViewById(R.id.button1);
btn2 = (Button) findViewById(R.id.button2);
btn1.setOnClickListener( this );
btn2.setOnClickListener( this );
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button1:
tst = Toast.makeText( this , "111111111" , Toast.LENGTH_SHORT);
tst.show();
break ;
case R.id.button2:
tst = Toast.makeText( this , "222222222" , Toast.LENGTH_SHORT);
tst.show();
break ;
default :
break ;
}
}
}
一、直接打開,不傳遞參數 Intent intent = new Intent(this, Activity.class);startActivity(intent);
二、傳遞參數
 public void OpenNew(View v) {
//新建一個顯式意圖,第一個參數為當前Activity類對象,第二個參數為你要打開的Activity類
Intent intent =new Intent(MainActivity.this,MainActivity2.class);
//用Bundle攜帶數據
Bundle bundle=new Bundle();
//傳遞name參數為tinyphp
bundle.putString("name", "tinyphp");
intent.putExtras(bundle);
startActivity(intent);
//1.要關閉的頁面
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.otheractivity);
Intent intent = this.getIntent();
intent.putExtra("tel", 12345);
//設置requestCode和帶有數據的intent對象
OtherActivity.this.setResult(3, intent);
//馬上關閉Activity
this.finish();
}
//2.上面的頁面關閉時,此頁面進行數據的接收
 class ButtonListener implements android.view.View.OnClickListener {
@Override
 public void onClick(View arg0) {
Intent intent = new Intent();
intent.setClass(MainActivity.this, OtherActivity.class);
//與普通的start方法不同,需要設置requestCode
startActivityForResult(intent, 1);
}
}
//如果要進行此操作,需要在數據接收頁面中復寫activity的onActivityResul()方法
@Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
int tel = 0;
//根據返回碼resultCode來判斷下一步進行的業務代碼
 if(resultCode==3) {
tel = data.getIntExtra("tel", 0);
}
Log.i(TAG, "tel--------->"+String.valueOf(tel));
}
}
三、回傳參數
|