当前位置: 编程技术>移动开发
本页文章导读:
▪ActivityGroup应用-怎么把一个Activity加载成一个视图 ActivityGroup应用-如何把一个Activity加载成一个视图
package com.test.activity.group;import android.app.ActivityGroup;import android.app.LocalActivityManager;import android.content.Intent;import android.os.Bundle;import android.view.Vi.........
▪ UI格局之selector layer-list UI布局之selector layer-list
1,当我们想把多个图层叠在一起现身的时候,可以使用layer-list
在drawable下建立一个xml文件 例如 login_head.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list
xmlns:androi.........
▪ MKMapView 怎么让map的anotation的callout自动显示 MKMapView 如何让地图的anotation的callout自动显示
我是这么来实现的.
首先在viewWillAppear 方法中定义了一个
[self performSelector:@selector(showCallout) withObject:nil afterDelay:1.0];
让方法showCallout在1.0秒.........
[1]ActivityGroup应用-怎么把一个Activity加载成一个视图
来源: 互联网 发布时间: 2014-02-18
ActivityGroup应用-如何把一个Activity加载成一个视图
package com.test.activity.group;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;
public class MainActivity extends ActivityGroup implements OnClickListener {
private ImageView mImgBtn1 = null;
private ImageView mImgBtn2 = null;
private ImageView mImgBtn3 = null;
private LocalActivityManager mActivityManager = null;
private LinearLayout contentlayout = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
contentlayout = (LinearLayout) findViewById(R.id.content);
mImgBtn1 = (ImageView) findViewById(R.id.btnModule1);
mImgBtn2 = (ImageView) findViewById(R.id.btnModule2);
mImgBtn3 = (ImageView) findViewById(R.id.btnModule3);
mImgBtn1.setOnClickListener(this);
mImgBtn2.setOnClickListener(this);
mImgBtn3.setOnClickListener(this);
mActivityManager = getLocalActivityManager();
}
@Override
public void onClick(View v) {
contentlayout.removeAllViews();
contentlayout.setVisibility(View.VISIBLE);
if (v.getId() == R.id.btnModule1) {
contentlayout.addView(mActivityManager.startActivity("",
new Intent(this, ActivityTest1.class)).getDecorView(),
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
}
else if(v.getId()==R.id.btnModule2){
contentlayout.addView(mActivityManager.startActivity("",
new Intent(this, ActivityTest2.class)).getDecorView(),
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
}else if(v.getId()==R.id.btnModule3){
contentlayout.addView(mActivityManager.startActivity("",
new Intent(this, ActivityTest3.class)).getDecorView(),
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
}
/*
* contentlayout.removeAllViews();
* contentlayout.setVisibility(View.VISIBLE);
* contentlayout.addView(mActivityManager.startActivity("",new
* Intent(this,
* ActivityTest1.class)).getDecorView(),LinearLayout.LayoutParams
* .FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
* Toast.makeText(this, "组件重绘", Toast.LENGTH_LONG).show(); // TODO
* Auto-generated method stub,contentlayout LinearLayout linear =
* (LinearLayout)findViewById(R.id.content); switch (v.getId()) { case
* R.id.btnModule1:
*
* linear.setVisibility(View.VISIBLE); mScroll.removeAllViews();
* mScroll.addView(mActivityManager.startActivity("",new Intent(this,
* ActivityTest1.class)).getDecorView()); break;
*
* case R.id.btnModule2: linear.setVisibility(View.VISIBLE);
* mScroll.removeAllViews();
* mScroll.addView(mActivityManager.startActivity("",new Intent(this,
* ActivityTest2.class)).getDecorView()); break; case R.id.btnModule3:
* break; }
*/
}
}
package com.test.activity.group;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast;
public class MainActivity extends ActivityGroup implements OnClickListener {
private ImageView mImgBtn1 = null;
private ImageView mImgBtn2 = null;
private ImageView mImgBtn3 = null;
private LocalActivityManager mActivityManager = null;
private LinearLayout contentlayout = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
contentlayout = (LinearLayout) findViewById(R.id.content);
mImgBtn1 = (ImageView) findViewById(R.id.btnModule1);
mImgBtn2 = (ImageView) findViewById(R.id.btnModule2);
mImgBtn3 = (ImageView) findViewById(R.id.btnModule3);
mImgBtn1.setOnClickListener(this);
mImgBtn2.setOnClickListener(this);
mImgBtn3.setOnClickListener(this);
mActivityManager = getLocalActivityManager();
}
@Override
public void onClick(View v) {
contentlayout.removeAllViews();
contentlayout.setVisibility(View.VISIBLE);
if (v.getId() == R.id.btnModule1) {
contentlayout.addView(mActivityManager.startActivity("",
new Intent(this, ActivityTest1.class)).getDecorView(),
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
}
else if(v.getId()==R.id.btnModule2){
contentlayout.addView(mActivityManager.startActivity("",
new Intent(this, ActivityTest2.class)).getDecorView(),
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
}else if(v.getId()==R.id.btnModule3){
contentlayout.addView(mActivityManager.startActivity("",
new Intent(this, ActivityTest3.class)).getDecorView(),
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT);
}
/*
* contentlayout.removeAllViews();
* contentlayout.setVisibility(View.VISIBLE);
* contentlayout.addView(mActivityManager.startActivity("",new
* Intent(this,
* ActivityTest1.class)).getDecorView(),LinearLayout.LayoutParams
* .FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT);
* Toast.makeText(this, "组件重绘", Toast.LENGTH_LONG).show(); // TODO
* Auto-generated method stub,contentlayout LinearLayout linear =
* (LinearLayout)findViewById(R.id.content); switch (v.getId()) { case
* R.id.btnModule1:
*
* linear.setVisibility(View.VISIBLE); mScroll.removeAllViews();
* mScroll.addView(mActivityManager.startActivity("",new Intent(this,
* ActivityTest1.class)).getDecorView()); break;
*
* case R.id.btnModule2: linear.setVisibility(View.VISIBLE);
* mScroll.removeAllViews();
* mScroll.addView(mActivityManager.startActivity("",new Intent(this,
* ActivityTest2.class)).getDecorView()); break; case R.id.btnModule3:
* break; }
*/
}
}
1 楼
xiaopei0714
2011-08-04
这个地方我也用ActivityGroup,所不同的是我是用的LinearLayout把一个个子Activity的view一起放入,而不是一次只是显示一个view,这样导致用getDecorView()之后那些view会带上边框,不知道可不可消掉这些边框
[2] UI格局之selector layer-list
来源: 互联网 发布时间: 2014-02-18
UI布局之selector layer-list
1,当我们想把多个图层叠在一起现身的时候,可以使用layer-list
在drawable下建立一个xml文件 例如 login_head.xml
<?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/user_faceback_drawable" android:drawable="@drawable/faceback" /> <item android:id="@+id/user_face_drawable" android:drawable="@drawable/h001" android:left="10.0dip" android:top="18.0dip" android:right="25.0dip" android:bottom="35.0dip" /> </layer-list>
其中facebook h001都是在drawable下的图片,这样就可以在layout xml文件中使用了
使用方法:
android:background="@drawable/login_head"
2,当我们像让界面随着动作的不同也改变时,例如当checkbox选中和没选中,或者获得焦点时,可以让它显示不同的状态,这些可以在java代码中通过捕捉事件来实现,也可以使用selector,并且更简单。
在drawable下建立一个xml文件,例如 check.xml
<?xml version="1.0" encoding="UTF-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/login_input" /> <item android:state_pressed="true" android:drawable="@drawable/login_input" /> <item android:state_focused="true" android:drawable="@drawable/input_over" /> </selector>
使用方法
android:background="@drawable/check"
[3] MKMapView 怎么让map的anotation的callout自动显示
来源: 互联网 发布时间: 2014-02-18
MKMapView 如何让地图的anotation的callout自动显示
我是这么来实现的.
首先在viewWillAppear 方法中定义了一个
[self performSelector:@selector(showCallout) withObject:nil afterDelay:1.0];
让方法showCallout在1.0秒钟后被调用.
- (void)showCallout {
[mapView selectAnnotation:attackedAnnotation animated:YES];
}
上面黄色的部分的方法是官方api中的方法.
1 楼
haipengno1
2011-01-18
你可以实现MKMapViewDelegate,在mapview的didAddAnnotationViews方法里面执行这个操作
最新技术文章: