嗨我有一个布局,我用来填充我的页面,我必须在我drawable folder的布局中设置一个背景图像.
我想alpha value将图像设置为相当低的几乎使图像像水印一样.
我的xml看起来像
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/main_background" >
Run Code Online (Sandbox Code Playgroud)
如您所见,我已为布局分配了一个ID
我想在我的创造中我可以做这样的事情吗?
View backgroundimage = (View) findViewById(R.id.background);
backgroundimage.setAlpha(80);
Run Code Online (Sandbox Code Playgroud)
这不起作用,但我怀疑它是因为我试图将背景作为View我应该把它投射为什么?
我有一个包含200多个对象的数组,我正试图通过每个对象执行循环.
每个对象都有一个是/否字段,我想显示一个不同的颜色标记,取决于是/否值.
从我所看到的情况发生,我的循环首先遍历每个对象,然后在每个对象的末尾添加所有注释.
因为当我将所有注释添加到我的地图时,在我的循环中通过数组对yes no值执行检查,它将使用数组中最后一个对象的yes/no值.
我怎样才能使标记根据每个元素的是/否值而不同?
我的代码是
for (i = 0; i < [appDelegate.itemArray count]; i++) {
item_details *tempObj = [appDelegate.itemArray objectAtIndex:i];
location.latitude = [tempObj.lat floatValue];
location.longitude = [tempObj.lon floatValue];
current_yesno = tempObj.yesno;
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc]initWithTitle:tempObj.name andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
[newAnnotation release];
}
Run Code Online (Sandbox Code Playgroud)
我的注释代码如下
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
if(current_yesno == YES){
annView.pinColor = MKPinAnnotationColorGreen;
}
else
{
annView.pinColor = MKPinAnnotationColorRed;
}
annView.animatesDrop=NO;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
return …Run Code Online (Sandbox Code Playgroud) 我使用Eclipse创建了一个应用程序,当连接到我的Deivce时,我选择运行.它等待调试器附加然后开始正常.
我的问题是,当我没有将设备连接到我的PC时,我仍然可以在应用程序列表中看到我的应用程序但是当我选择它时,我仍然会看到"等待调试程序附加"消息.我说的设备此时没有连接到我的电脑.
我以为,因为应用程序在我的列表中的APK安装在我的deivce本身让我怎么得到它停止尝试调试应用程序时(未连接到PC),只是运行它!
谢谢
android ×2
annotations ×1
background ×1
debugging ×1
eclipse ×1
ios ×1
mapkit ×1
objective-c ×1