我想一个alertdialog.But无法看到第二alertdialog..please帮助我在这里内添加alertdialog是我的代码所示
AlertDialog alertDialog = new AlertDialog.Builder(myclass.this).create();
alertDialog.setTitle("First alert");
alertDialog.setMessage("first alert press");
alertDialog.setButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// here you can add functions
dialog.cancel();
AlertDialog alertDialog1 = new AlertDialog.Builder(myclass.this).create();
alertDialog1.setTitle("second alert dialog");
alertDialog1.setMessage("second alert dialog details");
alertDialog1.setButton("Scan Another", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}}); }
Run Code Online (Sandbox Code Playgroud) 我有一个JEditorPane显示以编程方式生成的HTML(在运行时).到目前为止,当我添加"行"时,我在字符串缓冲区中重新创建整个HTML文本,然后将其传递给JEditorPane.setText方法.
现在创建的HTML变得非常大(可以达到几MB),我只想在最后添加我的新行,而不是重新生成所有HTML文本.
我试图在最后追加的原因是为了避免Swing(或套件?)必须再次渲染/解析整个文本.因为即使HTML生成不是在EDT中执行,而是在另一个swingworker线程中执行,"渲染"也需要很长时间.或者最好的是有一个显示渲染进度的进度条,这是不可能的(是吗?).
所以我的想法是简单地追加到最后,但如果你有更好的想法,欢迎!
由于我的文本是在HTML表格中格式化的,我想在此表的末尾附加我的新文本.为此,我尝试使用它insertBeforeEnd,HTMLDocument但即使我尝试了大量的解决方案,我也无法使它工作.请注意,我只有"table"标签.
这是我的代码的一部分
JEditorPane jep = new JEditorPane();
HTMLEditorKit kit = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();
jep.setEditorKit(kit);
jep.setDocument(doc);
//setting dummy text within a HTML table
jep.setText("<table><tr><td>A line of text</td></tr><tr><td>Another line of text</td></tr></table>");
Run Code Online (Sandbox Code Playgroud)
现在在这个表的末尾添加一些文本
//getting the Table Element
Element e = doc.getElement(doc.getDefaultRootElement(), StyleConstants.NameAttribute, HTML.Tag.TABLE);
Run Code Online (Sandbox Code Playgroud)
请注意,该元素似乎正确找到System.out.println(e.getName())"表"
现在
//inserting text at the end of the table
try {
doc.insertBeforeEnd(e, "<tr><td>A New Line</td></tr>");
} catch (BadLocationException ex) {
System.out.println(ex); …Run Code Online (Sandbox Code Playgroud) 我有一个自定义单元格的tableview,其动态单元格高度取决于单元格内容.
我的问题如下,当我在viewDidLoad中以编程方式询问滚动到它工作的给定位置,除了最后一行.有时行出现但不完整,有时甚至不出现.在这两种情况下,我都必须手动滚动才能看到该行.
这是代码:
[self.tableView reloadData];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:aRow inSection:aSection];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES ];
Run Code Online (Sandbox Code Playgroud)
这是iOS的错误吗?任何解决方法?
我有一个表视图,其中我的单元格高度是动态定义的,具体取决于它所代表的文本.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//getting my text for this cell, the row etc ...
...
//here is the part interesting us
NSAttributedString* theText = [myTextForThisCell objectAtIndex:indexPath.row];
NSInteger labelWidth = self.tableView.bounds.size.width-HORIZONTAL_CELL_PADDING;
CGSize textSize = [theText sizeWithFont:[UIFont systemFontOfSize:customFontSize] constrainedToSize:CGSizeMake(labelWidth, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
return textSize.height+VERTICAL_CELL_PADDING;
}
Run Code Online (Sandbox Code Playgroud)
好吧,现在我的问题.tableview是搜索操作的结果,扫描plist文件后显示包含给定字符串的行.
到目前为止就是这样.但是现在使用iOS 6和NSAttributedString可以轻松地加粗部分字符串,我决定加粗搜索字.
它正在工作,它大胆地说出我想要的单词,但现在我无法计算单元格高度,因为sizeWithFont要求NSString.并且由于粗体占用更宽的宽度,我不能简单地用没有属性的字符串计算单元格高度.
我只是被困在这里.
有人可以帮帮我吗?
如果尝试获取字符串对象,则(Xcode6 BETA 6)出错:
let jsonString : String = "[{\"name\":[\"Fred\",\"John\"],\"age\":21},{\"name\":\"Bob\",\"age\":35}]"
let myData:NSData? = jsonString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
var jsonResult:NSArray = NSJSONSerialization.JSONObjectWithData(myData!, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSArray
println(jsonResult.objectAtIndex(0).objectForKey("name").objectAtIndex(0))
Run Code Online (Sandbox Code Playgroud)
print永远不会被调用,导致错误.有人有想法吗?
有没有办法获得超过警报标题的2行AlertDialog?
我只找到"创建自定义对话框"作为可能的解决方案.
然而,理想情况下,人们可以设置attribute- 但我找不到任何.
编辑:
AlertDialog alertDialog = new AlertDialog.Builder(AlertAndCallUtility.this).create();
alertDialog.setTitle(getString(R.string.alert_title));
alertDialog.setMessage(getString(R.string.alert_msg));
alertDialog.setButton(getString(R.string.alert_OK),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
Run Code Online (Sandbox Code Playgroud)
和xml
<string name="alert_OK">OK:</string>
<string name="alert_title">Please correct your input, parameters are missing.</string>
<string name="alert_msg">Please enter them in the EXTRA tab.</string>
Run Code Online (Sandbox Code Playgroud)
如上所述,在"..missing"之前插入\n,只需将其剪掉,只有前两行才能看到标题的"是".
我NSMutableArray在我的.h文件中声明这样
@property (strong, nonatomic) NSMutableArray * numbers;
Run Code Online (Sandbox Code Playgroud)
如何使用NSMutableArray保存要保存的数据 NSUserDefaults
所有帮助表示赞赏
提前致谢
.h文件中的代码
@property (retain, nonatomic) IBOutlet UITableView *myTableView;
@property (strong, nonatomic) NSMutableArray * numbers;
Run Code Online (Sandbox Code Playgroud)
.m中的代码
@synthesize myTableView, numbers;
-(void) viewDidLoad
{
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
[defaults setObject:numbers forKey:@"numberArray"];
NSMutableArray *resultArray = [NSMutableArray arrayWithArray:[defaults objectForKey:@"numberArray"]];
[super viewDidLoad];
// instantiate our NSMutableArray
numbers = [[NSMutableArray alloc]initWithObjects:@"",@"", nil];
//Add a edit button
self.navigationItem.leftBarButtonItem = self.editButtonItem;
//Add the Add button
UIBarButtonItem * addButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target: self action: @selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = …Run Code Online (Sandbox Code Playgroud) 我正在尝试“学习Java”中关于RersourceBundles 的示例。
我使用的是 Windows 7 和 NetBeans
示例代码为:
import java.util.*;
public class Hello {
public static void main(String[] args) {
ResourceBundle bun;
bun = ResourceBundle.getBundle("Message", Locale.ITALY);
System.out.println(bun.getString("HelloMessage"));
bun = ResourceBundle.getBundle("Message", Locale.US);
System.out.println(bun.getString("HelloMessage"));
}
}
Run Code Online (Sandbox Code Playgroud)
如果我运行代码我得到:
线程“main”中的异常 java.util.MissingResourceException:找不到基名称消息的包,在 java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499) 处的 java.util.ResourceBundle.getBundleImpl(ResourceBundle. java:1322)在java.util.ResourceBundle.getBundle(ResourceBundle.java:795)在学习java4.Hello.main(Hello.java:14)Java结果:1
即使我写了并保存
import java.util.*;
public class Message_it_IT extends ListResourceBundle {
public Object[][] getContents() {
return contents;
}
static final Object[][] contents = {
{"HelloMessage", "Buon giorno, world!"},
{"OtherMessage", "Ciao."},
};
}
Run Code Online (Sandbox Code Playgroud)
我仍然有同样的错误。文件 Message_it_IT 保存在另一个文件的同一目录中,出了什么问题?
谢谢
我想模仿似乎是使用UISearchBar的标准UI,现在我尝试将其余视图设置为灰色,当我开始搜索时,我尝试通过将视图的背景颜色设置为灰色,但我在UITableView中使用了部分,并且它们没有变灰.任何人有任何理由为什么?

基本上我开始将一个纯粹的活动应用程序移植到Fragments,我几乎陷入了第一步.
在我当前的应用程序中,我扩展应用程序以访问用于自定义应用程序的全局常量和变量.
public class MyApplication extends Application {
private final int nbreLivres = 50;
private final String[] nomsLivres = new String[nbreLivres];
private final int colorCount = 25;
private final int[] customColors = new int[colorCount];
private SparseIntArray hmColors = new SparseIntArray();
private int mCustomFontSize = 14;
private static MyApplication instance;
...
...
public int getColorCount() {
return colorCount;
}
public int getColorFromIndex(int index) {
return customColors[index];
}
...
...
...
}
Run Code Online (Sandbox Code Playgroud)
从活动中访问这些我做的事情
((MyApplication) this.getApplication()).getColorCount();
Run Code Online (Sandbox Code Playgroud)
如果我需要用我做的实例访问它
private MyApplication mApp = MyApplication.getMyApplication();
mApp.getColorCount(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试重新创建这种效果(见下图),但是有一个圆形路径,因为我有一个圆形按钮.
这是源头.
https://github.com/uiue/ParticleButton/blob/master/ParticleButton/EmitterView.m
我所做的修改似乎影响了粒子动画的方法,而不是路径.
我没有深入研究过所使用的技术,但我不相信这是可能的吗?
fireEmitter = (CAEmitterLayer *)self.layer;
//fireEmitter.renderMode = kCAEmitterLayerAdditive;
//fireEmitter.emitterShape = kCAEmitterLayerLine;
// CGPoint pt = [[touches anyObject] locationInView:self];
float multiplier = 0.25f;
fireEmitter.emitterPosition = self.center;
fireEmitter.emitterMode = kCAEmitterLayerOutline;
fireEmitter.emitterShape = kCAEmitterLayerCircle;
fireEmitter.renderMode = kCAEmitterLayerAdditive;
fireEmitter.emitterSize = CGSizeMake(100 * multiplier, 0);
Run Code Online (Sandbox Code Playgroud)

我有以下问题.
我正在使用Delphi 2010,最近我安装了Delphi XE2并重新编译了我的不同项目.我注意到了一个错误?在tchart的pointseries中.
当我向点系列添加点数时,最后一个点不显示或仅在没有显示其他点时???
一开始画的一切都很好:

然后我清除系列并重新添加相同的点.最后一点不显示

但是,如果我滑动图表以便屏幕上不显示其他点,则会显示此缺失点

有什么想法或帮助吗?
是将实例作为Orphan在finally块中请求GC以高优先级执行垃圾收集吗?
SQLConnect ds =null;
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
...
variables
try {
//Business Logic
} catch(Exception e) {
//Logging goes here
} finally {
//Make instances Orphan
ds = null;
con = null;
pstmt = null;
rs = null;
}
Run Code Online (Sandbox Code Playgroud) ios ×4
android ×3
java ×3
objective-c ×3
uitableview ×2
calayer ×1
cocoa-touch ×1
delphi ×1
delphi-xe2 ×1
dom ×1
fragment ×1
ios6 ×1
ios7 ×1
jeditorpane ×1
jtextpane ×1
memory-leaks ×1
scroll ×1
swift ×1
swing ×1
teechart ×1
uisearchbar ×1
xcode ×1
xcode6-beta6 ×1