我有一个ListView,每行包含一个CheckedTextView.我正在使用自定义checkMark属性,该属性使用drawable:
<CheckedTextView
android:id="@+id/body"
android:gravity="left"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_below="@+id/date"
android:textSize="18sp"
android:checkMark="@drawable/checkbox_selector"
/>
Run Code Online (Sandbox Code Playgroud)
drawable checkbox_selector按预期正确处理'on'和'off'选项,如下所示:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_selected="true" android:state_pressed="true"
android:drawable="@drawable/checkbox_on" >
</item>
<item android:state_pressed="true" android:drawable="@drawable/checkbox_on" />
<item android:state_checked="true" android:drawable="@drawable/checkbox_on"/>
<item android:drawable="@drawable/checkbox_off" />
</selector>
Run Code Online (Sandbox Code Playgroud)
以下是当前ListView布局的屏幕截图:

如您所见,复选框顶部对齐.有没有办法让它正中心呢?检查选择器资源的属性,我找不到任何相关的属性来执行此操作.
有什么方法可以调整它的位置吗?感谢您的时间.
我正在使用Xcode 6.0.1,iOS8和Swift.我必须在Settings-> General中重现我自动锁定选项UITableView的相同行为.在Objective-C中,我写过
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CheckMarkCellIdentifier = @"CheckMarkCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CheckMarkCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CheckMarkCellIdentifier] autorelease];
}
cell.textLabel.text = ...
cell.detailTextLabel.text = ...;
cell.accessoryType = [indexPath isEqual: self.lastSelectedIndexPath] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = indexPath.row;
int oldRow = self.lastSelectedIndexPath.row;
if (newRow != oldRow) {
UITableViewCell *newCell = [tableView …Run Code Online (Sandbox Code Playgroud) 我需要在UIActionSheet中标记所选按钮.
如何在UIActionSheet按钮中添加复选标记?
是否有一些特定于UIActionSheet的方法,没有标准的按钮内添加图像.
我正在尝试实现类似于BEMAnimationTypeStroke的东西,它可以在iOS库BEMCheckBox中找到.
我已经尝试使用动画矢量drawable来实现这一点,但我不知道如何设置圆圈内的复选标记从0起点到最终位置的动画.(圆圈可以是静态的,我希望为复选标记设置动画).这是我为此尝试的实现:
绘制/ vector_drawable_ic_check_circle_white_48px.xml
<path
android:name="check"
android:fillColor="#FFFFFF"
android:pathData="M37.1,13.6L18.4,32.3h1.7l-8.5-8.5L10,25.5l8.5,8.5l0.8,0.8l0.8-0.8l18.7-18.7L37.1,13.6L37.1,13.6z"/>
<path
android:name="circle"
android:fillColor="#FFFFFF"
android:pathData="M24,48c13.3,0,24-10.7,24-24S37.3,0,24,0S0,10.7,0,24S10.7,48,24,48L24,48z
M24,45.6
C12.1,45.6,2.4,35.9,2.4,24S12.1,2.4,24,2.4S45.6,12.1,45.6,24S35.9,45.6,24,45.6L24,45.6z"/>
</vector>
Run Code Online (Sandbox Code Playgroud)
动画/ transform.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="1000"
android:propertyName="fillColor"
android:valueFrom="@color/transparent"
android:valueTo="@color/white"/>
</set>
Run Code Online (Sandbox Code Playgroud)
绘制/ animation.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/vector_drawable_ic_check_circle_white_48px">
<target
android:name="check"
android:animation="@anim/change_color"/>
</animated-vector>
Run Code Online (Sandbox Code Playgroud)
设置布局后,我使用以下命令启动动画:
ImageView mCpuImageView = (ImageView) findViewById(R.id.animated_check);
Drawable drawable = mCpuImageView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我这个?有没有更简单的方法来实现这一点(自定义视图或现有库)?
我的想法是,我希望在一个圆圈中有一个复选标记,我想要勾选复选标记的路径.显示时,只显示圆圈,然后创建复选标记动画.如果其他自定义,例如同时为复选标记设置动画的动画,则很容易实现它会更好,但起初我只想为复选标记设置动画.
LE: 最后我选择了通过自定义View手动创建动画的方法.如果有人知道如何通过矢量绘制实现这一点,它将是一个很好的开发实践.谢谢.
我正在构建一个主细节应用程序.我有一个部分视图控制器(VC),它是主VC的子代.单击VC部分中的行会显示用户完成所需信息的不同详细信息VC.一旦详细VC中的信息完成,我希望在VC行的相关部分中显示复选标记.FYI selectedProject是核心数据对象.
我在详细VC viewWillDisappear中调用通知来刷新VC部分.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
let detailCase: String = selectedProject!.section![indexPath.row]
configureCell(cell, withSectionName: detailCase)
print("location complete is \(selectedProject!.completeLocation)")
print("electricity complete is \(selectedProject!.completeElectricity)"
print(cell.textLabel!.text!)
print(cell.accessoryType.rawValue)
return cell
}
func configureCell(_ cell: UITableViewCell, withSectionName sectionName: String) {
switch sectionName {
case "Project Details" :
cell.accessoryType = .checkmark
case "Location" :
if selectedProject?.completeLocation == true {
cell.accessoryType = .checkmark
}
case "Electricity Use" :
if selectedProject?.completeElectricity == …Run Code Online (Sandbox Code Playgroud) 我有一个ListActivity,其数组适配器声明为像arrayAdapter = new ArrayAdapter<String> (this, android.R.layout.simple_list_item_checked);这样在最右边显示了一堆带有复选标记的行.你能告诉我如何获得这些复选标记的引用或如何检查/取消选中它们吗?
我是ios开发的新手,我在一个单元格中使用了checkmark UITableView.
我想在NSUserDefaults数据库中存储已检查的单元格,当我重新加载应用程序时,将显示之前选中的已检查单元格,我尝试不同的方式,但仍未能实现它.
有人可以帮帮我吗?我将非常感激.对不起,我的英语不好.
我的代码如下:
#import "FirstRowSubview.h"
@interface FirstRowSubview ()
@end
@implementation FirstRowSubview
@synthesize array = _array;
@synthesize lastIndexPath = _lastIndexPath;
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *list = [[NSMutableArray alloc] initWithObjects:@"ffgfgh", @"564654", @"56548", @"fgmjfgmf", @"ggkdj", nil];
self.array = list;
[list release];
}
- (void)viewDidUnload
{
[super viewDidUnload];
self.array = nil;
}
#pragma mark -
#pragma mark - TableView Datasource Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试用我自己的复选标记(实际上是路径)替换标准WPF复选框的复选标记.该复选框应该看起来像标准复选框.
我在哪里可以找到复选框的Microsoft xaml模板,所以我可以在xaml中修改它?或者有更优雅的方式吗?
注意:我在MSDN上找到了一个模板(http://msdn.microsoft.com/en-us/library/ms752319%28v=vs.110%29.aspx),但它看起来完全不同.
此致,BlackTuareg
我使用swift 2和UITableViews,当我按下一个单元格时会出现一个复选标记,但我不想在我的tableview中只检查一个单元格,所以其他复选标记将从我的tableview中消失.我尝试了不同的技术而没有成功.我有一个只有标签的CustomCell.
这是我的代码:
import UIKit
class MyViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
@IBOutlet weak var tableView: UITableView!
var answersList: [String] = ["One","Two","Three","Four","Five"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return answersList.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("MyCustomCell", forIndexPath: indexPath) as! MyCustomCell
cell.displayAnswers(answersList[indexPath.row]) // My cell is just a label
return cell …Run Code Online (Sandbox Code Playgroud)