ImageVerifierCode 换一换
格式:DOCX , 页数:30 ,大小:23.64KB ,
资源ID:9073549      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9073549.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Java Codes.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Java Codes.docx

1、Java CodesJava Android CodesActivity AndroidManifest.xml Home.java package com.wpirl; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import com.wpirl.activity.Dire

2、ctoryActivity; import com.wpirl.activity.MapActivity; import com.wpirl.activity.RouteActivity; import com.wpirl.map.Map; import com.wpirl.positioning.Positioning; public class Home extends Activity implements OnClickListener private Button btnMapActivity; private Button btnRouteActivity; private But

3、ton btnDirectoryActivity; /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.home); btnMapActivity = (Button) findViewById(R.id.btnMapActivity); btnMapActivity.setOnClickListener(this);

4、 btnRouteActivity = (Button) findViewById(R.id.btnRouteActivity); btnRouteActivity.setOnClickListener(this); btnDirectoryActivity = (Button) findViewById(R.id.btnDirectoryActivity); btnDirectoryActivity.setOnClickListener(this); initialize(); public void onClick(View v) if (v = btnMapActivity) start

5、Activity(new Intent(Home.this, MapActivity.class); else if (v = btnRouteActivity) startActivity(new Intent(Home.this, RouteActivity.class); else if (v = btnDirectoryActivity) startActivity(new Intent(Home.this, DirectoryActivity.class); /* * Initialize all the static classes */ private void initiali

6、ze() Map.initialize(); Positioning.initialize(); Home.xml Directory.java package com.wpirl.activity; import java.util.Arrays; import android.app.ExpandableListActivity; import android.content.Intent; import android.os.Bundle; import android.view.ContextMenu; import android.view.Gravity; import andro

7、id.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ContextMenu.ContextMenuInfo; import android.widget.AbsListView; import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListAdapter; import android.widget

8、.ExpandableListView; import android.widget.TextView; import android.widget.Toast; import android.widget.ExpandableListView.ExpandableListContextMenuInfo; import com.wpirl.map.GraphNode; import com.wpirl.map.Map; public class DirectoryActivity extends ExpandableListActivity private static final int M

9、ENU_VIEW_DETAIL = Menu.FIRST + 1; private static final int MENU_FROM_HERE = Menu.FIRST + 2; private static final int MENU_TO_HERE = Menu.FIRST + 3; / Sample data set. childreni contains the children (String) for groupsi. private final String groups = Room, Name ; private String children = new String

10、2; ExpandableListAdapter adapter; Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); / Set up our adapter adapter = new DirectoryExpandableListAdapter(); children0 = Map.getRooms(); Arrays.sort(children0); children1 = Map.getPeople(); Arrays.sort(children1);

11、 setListAdapter(adapter); registerForContextMenu(getExpandableListView(); Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) menu.setHeaderTitle(Menu); menu.add(0, MENU_VIEW_DETAIL, 0, View Detail); menu.add(0, MENU_FROM_HERE, 0, From Here); menu.add(0, MENU

12、_TO_HERE, 0, To Here); Override public boolean onContextItemSelected(MenuItem item) ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo(); String title = (TextView) info.targetView).getText().toString(); int type = ExpandableListView.getPackedPositionType(info.packe

13、dPosition); int id = item.getItemId(); /* * If the menu clicked is the child */ if (type = ExpandableListView.PACKED_POSITION_TYPE_CHILD) GraphNode node = Map.searchDetail(title); switch (id) case MENU_VIEW_DETAIL: StringBuilder sb = new StringBuilder();sb.append(Detail informationn); sb.append(Room

14、 ID: + node.room + n); sb.append(Name: + node.person + n); Toast.makeText(this, sb.toString(), Toast.LENGTH_LONG).show(); break; case MENU_FROM_HERE: Map.setRoutingSource(node); startActivity(new Intent(this, RouteActivity.class); break; case MENU_TO_HERE: Map.setRoutingDestination(node); startActiv

15、ity(new Intent(this, RouteActivity.class); break; return true; /* * If the menu clicked is the group */ else if (type = ExpandableListView.PACKED_POSITION_TYPE_GROUP) int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); if (groupPos = 0) Toast.makeText( this, This group con

16、tains the list of rooms in this building, Toast.LENGTH_SHORT).show(); else Toast.makeText( this, This group contains the list of names in this building, Toast.LENGTH_SHORT).show(); return true; return false; /* * */ public class DirectoryExpandableListAdapter extends BaseExpandableListAdapter public

17、 Object getChild(int groupPosition, int childPosition) return childrengroupPositionchildPosition; public long getChildId(int groupPosition, int childPosition) return childPosition; public int getChildrenCount(int groupPosition) return childrengroupPosition.length; public TextView getGenericView() /

18、Layout parameters for the ExpandableListView AbsListView.LayoutParams lp = new AbsListView.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, 64); TextView textView = new TextView(DirectoryActivity.this); textView.setLayoutParams(lp); / Center the text verticallytextView.setGravity(Gravity.CENTER_VER

19、TICAL | Gravity.LEFT);/ Set the text starting position textView.setPadding(36, 0, 0, 0);return textView; public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) TextView textView = getGenericView();textView.setText(getChild(groupPositio

20、n, childPosition).toString();return textView; public Object getGroup(int groupPosition) return groupsgroupPosition;public int getGroupCount() return groups.length;public long getGroupId(int groupPosition) return groupPosition; public View getGroupView(int groupPosition, boolean isExpanded, View conv

21、ertView, ViewGroup parent) TextView textView = getGenericView();textView.setText(getGroup(groupPosition).toString(); return textView;public boolean isChildSelectable(int groupPosition, int childPosition) return true; public boolean hasStableIds() return true; RouteActivity.java package com.wpirl.act

22、ivity; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.Toast;

23、import com.wpirl.R; import com.wpirl.map.GraphNode; import com.wpirl.map.Map; public class RouteActivity extends Activity implements OnClickListener private GraphNode source; private GraphNode destination; private AutoCompleteTextView textViewSource; private AutoCompleteTextView textViewDestination;

24、 private Button btnSearch; Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.route); String database = Map.getDatabase(Map.DATABASE_PERSON + Map.DATABASE_ROOM); ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, database); btnSearch = (Button) findViewById(R.id.btnSearchRoute); btnSearch.setOnClickListener(this); textViewSource = (AutoCompleteTextView) findViewById(R.id.editSource); textViewSource.setAdapter(adapter); textViewDestination = (AutoCompleteTextView) findViewById(R.id.edi

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1