Android开发点滴-程序员宅基地

技术标签: button  Android开发  string  application  null  android  listview  

Android开发点滴:

1)固定屏幕纵向<activity android:name=".C6UsersActivity" android:label="@string/app_name" android:screenOrientation="portrait"></activity>  landscape为横向

2)网络访问权限<uses-permission android:name="android.permission.INTERNET" />

3)本地读写权限<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>

4)多线程执行

new Thread(){
    		public void run(){
    			Log.d("ApplicationSet","Reflesh UserList begin...");
            	         Log.d("ApplicationSet","Reflesh UserList End...");
        		}
        	}.start();


 5)ListAcitvity示例

package C6M.Package;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;

import C6M.Application.C6MApplication;
import C6M.ConfigOper.ConfigOper;
import C6M.Organization.Dept;
import C6M.Organization.Organization;
import C6M.Organization.User;
import C6M.ServicesOper.SHA1;
import C6M.ServicesOper.ServicesOper;
import android.R.color;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class C6UsersActivity extends ListActivity {
	public String serviceurl="******";
	public Organization organization=null;
	public String userlist="";
	public Thread userthread=null;
	@Override
    public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.users);
        Button btnSearch=(Button)findViewById(R.id.btnSearch);
        btnSearch.setOnClickListener(btnClickListener);
        //getUsers();
	}
	protected void onListItemClick(ListView l, View v, int position, long id) {    
		// TODO Auto-generated method stub    
		super.onListItemClick(l, v, position, id);  
		try
		{
			
		    System.out.println("id--------------" + v.getId());    
	        System.out.println("position--------------" + position);    
	        ListView listView = (ListView)l;  
	        HashMap<String, String> map = (HashMap<String, String>) listView.getItemAtPosition(position);  
	        String _userid = map.get("txtUserId");  
		    //String _userid=((TextView)l.getChildAt(position).findViewById(R.id.txtUserId)).getText().toString();
		    Intent intent = new Intent(C6UsersActivity.this,CallSendActivity.class);   
   	        intent.putExtra("UserId",_userid);   
   	        startActivity(intent);
		}catch(Exception e)
		{
			Log.d("Application", "Start CallSend Error "+e.getMessage());
		}
	}
    //按钮点击监听操作
    public OnClickListener btnClickListener=new OnClickListener()
    {
    	@Override
		public void onClick(View v) {
    		Log.d("ApplicationKey","Begin");
    	  int id=v.getId();
    	  String _Key="" ;
    	  EditText editkey=(EditText)findViewById(R.id.txtKey);
    	  _Key=editkey.getText().toString();
    	  Log.d("ApplicationKey",_Key);
    	  switch(id)
    	  {
    	     case R.id.btnSearch:
    	    	 CreatUserList(_Key);
    	    	 break;
    	  }
    	}
    };

    //获取用户列表
    public Organization GetOrganization()
    {
    	Organization _ret=new Organization();
    	String _classarray=",DeptList,ChildUsers,";
        _ret=(Organization)ServicesOper.GetObjectInfo(new File("sdcard/C6M/UserList.dat"),"C6M.Organization",_classarray);
    	return _ret;
    }
    //创建用户列表
    public void CreatUserList(String _Key)
    {
    	if(C6MApplication.organization==null)
    	{
    		 return;
    	}
    	int count=0;
    	//_Key=_Key+"李";
    	Organization _org=C6MApplication.organization;
        ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String,String>>();
    	for(int i=0;i<_org.DeptList.size();i++)
    	{
    		Dept _dept=(Dept)_org.DeptList.get(i);
    		for(int j=0;j<_dept.ChildUsers.size();j++)
    		{
    			//Log.d("CreatTree", "UserBegin "+String.valueOf(_Key.length()));
    			User _user=(User)_dept.ChildUsers.get(j);
    			//if(_Key.length()>0)
    			if(_Key!=null &&!_Key.equals("")&&_user.UserName.lastIndexOf(_Key)<0) 
    			 		continue;
    	        HashMap<String, String> map1 = new HashMap<String, String>();
    	        map1.put("txtUserName", _user.UserName);
    	        map1.put("txtUserId", _user.UserId);
    	        list.add(map1);
    	        count++;
    	        Log.d("CreatTree", "UserEnd");
    		   // if(count>20) break;
    		}
    		//if(count>20) break;
    	}
    	Log.d("Application",String.valueOf(list.size()));
    	
        //生成一个SimpleAdapter类型的变量来填充数据
        SimpleAdapter listAdapter = new SimpleAdapter(this, list, R.layout.user, new String[]{"txtUserName" , "txtUserId"}, new int[]{R.id.txtUserName , R.id.txtUserId});
        setListAdapter(listAdapter);
    }
}


 自定义弹出窗口实现

    @Override
    public boolean onPrepareOptionsMenu(Menu menu)
    {
    	showTopWindow();
    	return true;
    }
 	public void showTopWindow(){
 		if(Setalert==null)
 		{
 		    LayoutInflater flater = LayoutInflater.from(this);
 	        view = flater.inflate(R.layout.menu, null);
 		
 		    Log.d("T","show beg");
 	        AlertDialog.Builder builder = new AlertDialog.Builder(C6UnReadMsg.this); 
        	builder.setView(view);
    	    Setalert = builder.create();  	   
 	        Setalert.show();
 	        //((TextView)(view.findViewById(R.id.txtAddress))).setText(C6MApplication.ServiceUrl);
 	        ImageButton btnSet=(ImageButton)view.findViewById(R.id.btnUserList);
 	        btnSet.setOnClickListener(btnClickListener);
 	       Log.d("T","show end");
 		}else
 		{
 			Setalert.show();
 		}
 	}


 

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/LovingCatsFish/article/details/6853883

智能推荐

三分钟了解Activity工作流-程序员宅基地

文章浏览阅读2.1w次,点赞10次,收藏47次。文章目录一、 什么是工作流二、 工作流技术的优点三、 Java开发者会为什么要学Activity工作流四、 Activity工作流学习要点1、1个插件2、1个引擎3、1个配置文件4、5种数据库表5、23张表6、5项Service7、7项基本操作一、 什么是工作流以请假为例,现在大多数公司的请假流程是这样的员工打电话(或网聊)向上级提出请假申请——上级口头同意——上级将请假记录下来——月底将请假记录上交公司——公司将请假录入电脑采用工作流技术的公司的请假流程是这样的员工使用账户登录系统——点击请假—_activity工作流

c++课程作业-程序员宅基地

文章浏览阅读594次。#include #include #include#includeusing namespace std; class Student //通过定义一个类来定义数据录入的函数 { char name[20]; char number[20]; float maogai,modian,shudian,cpp,english,average,sum; int ta_c++课程作业

力扣经典150题第四十二题:字母异位词分组-程序员宅基地

文章浏览阅读985次,点赞16次,收藏19次。本篇博客介绍了力扣经典150题中的第四十二题:字母异位词分组。题目要求将给定的字符串数组中的字母异位词分组,并返回分组结果。输入: strs = [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],将其中字母异位词(由重新排列源单词的所有字母得到的新单词)组合在一起,最终返回分组后的结果列表。输出: [[“bat”],[“nat”,“tan”],[“ate”,“eat”,“tea”]]的长度,k 是字符串的最大长度。展示了几个不同的示例测试,验证了字母异位词分组的功能。

springboot报错---@RunWith(SpringRunner.class)_springrunner.class报错-程序员宅基地

文章浏览阅读2.4k次。@RunWith(SpringRunner.class)因为缺乏pom文件里Junit依赖导致。解决方法:在pom.xml里添加以下依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </_springrunner.class报错

boost/lexical_cast.hpp的简单使用方法_行动_新浪博客-程序员宅基地

文章浏览阅读264次。boost/lexical_cast.hpp的简单使用方法_行动_新浪博客 boost/lexical_cast.hpp的简单使用方法_行动_新浪博客 boost/lexical_cast.hpp的简单使用方法 (2010-03-19 16:31:13)..._boost/lexical_cast.hpp

DELL戴尔服务器Windows Server 2008 2012 操作系统安装指导-U盘安装_戴尔s150阵列卡驱动2012_dell s150阵列-程序员宅基地

文章浏览阅读815次,点赞10次,收藏17次。4.2.如果是server2008,那么首先检查RAID是否配好,然后准备另外一个U盘,我们命名为U盘2,把阵列卡驱动放到U盘2中,插在服务器上,此时服务器插着两个U盘,一个是启动盘,一个是U盘2,在看到以上提示时,我们点击Load driver,然后如下图,点击浏览Browse,然后找到阵列卡驱动路径,一般是一个EXE可执行文件,选好后,下一步即可。2.以防步骤1中硬盘与服务器连接有问题,那么在服务器完全关机且切断电源的情况下,需要将硬盘拔下清理灰尘,在重新插上,然后上电开机。配置,而要 Import!_dell s150阵列

随便推点

开发与研发-程序员宅基地

文章浏览阅读229次。转:http://blog.sae.sina.com.cn/archives/981按:这几天我一直在写这篇东西,本来是胸有成竹,没想到后来越写越发现自己在这个题目下有太多话想说,而以我现在的能力又不能很好地概括总结,以至于越写越长,文章结构也变得混乱,到后来修改的时候每次都要考虑好久才能下笔,所以决定拆成两部分来发,以便阅读。这篇写得我心力交瘁,质量不算好,凑合着看吧。同样是写程序..._研发和开发

关于android双进程守护-后台持续定位功能+项目IM中写到自己的即时通讯_jobintentservice跨进程-程序员宅基地

文章浏览阅读1.6k次。1.关于进程守护无非就是6.0以下,6.0以上的高版本保活a.android中6.0以下的保护采用双线程守护即可是aidl (1)创建aidl文件 interface IServiceAidlInterface { String getServiceName(); } (2)创建本地service是LocalService类实现aid..._jobintentservice跨进程

FastGithub:github加速神器,解决github打不开、用户头像无法加载、releases无法上传下载、git-clone、git-pull、git-push失败等问题。_fastgithub 程序将自动关闭:系统已运行其它实例-程序员宅基地

文章浏览阅读657次。FastGithub:github加速神器,解决github打不开、用户头像无法加载、releases无法上传下载、git-clone、git-pull、git-push失败等问题。_fastgithub 程序将自动关闭:系统已运行其它实例

c++ 去除字符串中的空格和标点符号 (remove_if 函数的用法)_ctype.h去除空格-程序员宅基地

文章浏览阅读1.7w次,点赞8次,收藏26次。C++中提供了自动删除空格和标点符号的函数,使用如下:#include #include str_testing.erase( remove_if ( str_testing.begin(), str_testing.end(), static_cast(&ispunct) ), str_testing.end()); str_testing.erase( _ctype.h去除空格

单片机设计_俄罗斯方块游戏(AT89C51 LCD12864)_基于51单片机俄罗斯方块-程序员宅基地

文章浏览阅读7.2k次,点赞9次,收藏80次。此电路由AT89C51最小系统、12864显示模块和独立按键组成。可实现类似俄罗斯方块的游戏。_基于51单片机俄罗斯方块

中石油企业微信私有版设置服务器,企业微信授权配置教程-程序员宅基地

文章浏览阅读4k次。# **企业微信授权配置教程**## **1.创建企业微信应用*** 注册进入企业微信后台 https://work.weixin.qq.com/![](https://img.kancloud.cn/97/7b/977b19f10dcc10d42d70f14503b79d2a_1920x881.png)>[danger] ## **请先关闭自动欢迎语【重要】 设置欢迎语或直接导致无法收到*..._中石油企业微信 组织机构域

推荐文章

热门文章

相关标签