小编HpT*_*erm的帖子

WPF图表控件

我正在寻找一个非常简单的WPF图表,它应该有一个2D图形,并且应该有平移和缩放功能.

c# wpf charts

178
推荐指数
7
解决办法
25万
查看次数

在Android上将字符串转换为整数

如何将字符串转换为整数?

我有一个文本框我让用户输入一个数字:

EditText et = (EditText) findViewById(R.id.entry1);
String hello = et.getText().toString();
Run Code Online (Sandbox Code Playgroud)

并将值分配给字符串hello.

我想将它转换为整数,这样我就可以得到他们输入的数字; 它将在稍后的代码中使用.

有没有办法得到EditText一个整数?那会跳过中间人.如果没有,字符串到整数就可以了.

java string android integer android-edittext

173
推荐指数
10
解决办法
52万
查看次数

从资产中读取文件

public class Utils {
    public static List<Message> getMessages() {
        //File file = new File("file:///android_asset/helloworld.txt");
        AssetManager assetManager = getAssets();
        InputStream ims = assetManager.open("helloworld.txt");    
     }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码尝试从资产中读取文件.我尝试了两种方法来做到这一点.首先,当File我收到使用FileNotFoundException时,使用AssetManager getAssets()方法时无法识别.这里有解决方案吗?

android

167
推荐指数
8
解决办法
31万
查看次数

Android Lollipop,AppCompat ActionBar自定义视图不占用整个屏幕宽度

所以,我刚刚将我的代码库更新为Lollipop,而且我遇到了Action Bar的问题.我正在使用AppCompat和ActionBarActivity,并为自定义视图充气.似乎自定义视图不再占据屏幕的整个宽度,在左侧留下一条细条

建筑用19 过去的样子

建筑用21 它看起来现在的样子

这是我用来设置Action Bar的代码.有人有主意吗?

final ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setCustomView(R.layout.action_bar_content_search_custom_view);
    actionBar.setBackgroundDrawable(null);
    // actionBar.setStackedBackgroundDrawable(null);
    TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title);
    title.setText(R.string.youtube);
    ImageView back = (ImageView) actionBar.getCustomView().findViewById(R.id.action_bar_back);
    back.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

编辑

取出自定义视图并更改背景现在占用整个宽度.问题是,我们如何让CustomView占用ActionBar的整个宽度?

android android-appcompat android-actionbar android-5.0-lollipop

96
推荐指数
4
解决办法
5万
查看次数

如何在Swift中设置UIBarButtonItem的操作

如何设置Swift中自定义UIBarButtonItem的操作?

以下代码成功将按钮放在导航栏中:

var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:nil)
self.navigationItem.rightBarButtonItem = b
Run Code Online (Sandbox Code Playgroud)

现在,我想func sayHello() { println("Hello") }在触摸按钮时打电话.到目前为止我的努力:

var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:sayHello:)
// also with `sayHello` `sayHello()`, and `sayHello():`
Run Code Online (Sandbox Code Playgroud)

和..

var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:@selector(sayHello:))
// also with `sayHello` `sayHello()`, and `sayHello():`
Run Code Online (Sandbox Code Playgroud)

和..

var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:@selector(self.sayHello:))
// also with `self.sayHello` `self.sayHello()`, and `self.sayHello():`
Run Code Online (Sandbox Code Playgroud)

请注意,它sayHello()出现在intellisense中,但不起作用.

谢谢你的帮助.

编辑:对于后代,以下工作: …

action uibarbuttonitem ios swift

78
推荐指数
3
解决办法
10万
查看次数

UIActionSheet没有在iOS 7 GM上的最后一项显示分隔符

这可能是iOS7上的一个错误.但是最后一个按钮与前一个按钮没有分开UIActionSheet在最后一个按钮上缺少分隔符

从图像中可以看出.使用iOS7 GM在Simulator和设备上都会发生这种情况.其他人都有同样的问题吗?

UIActionSheet *actionSheet = [[UIActionSheet alloc]
               initWithTitle:@"Title"
               delegate:self
               cancelButtonTitle:nil
               destructiveButtonTitle:nil
               otherButtonTitles:@"First", @"Second", @"Third", @"Fourth", nil];
[actionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,代码非常简单.有关如何解决问题的任何想法?或者我可以使用一些第三方库而不是UIActionSheet?

iphone uikit uiactionsheet ios ios7

46
推荐指数
5
解决办法
1万
查看次数

未调用AppCompat v7工具栏onOptionsItemSelected

我从原来的ActionBar更改为AppCompat工具栏和setSupportActionBar(工具栏).当我使用getSupportActionBar()和setDisplayHomeAsUpEnabled(true)作为后退箭头时,单击从不调用onOptionsItemSelected或任何其他侦听器方法.

我必须为它实现一些特殊的监听器吗?一切都工作得很好.

编辑:初始化ActionBar:

mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
mActionBar = getSupportActionBar();
mActionBar.setHomeButtonEnabled(true);
Run Code Online (Sandbox Code Playgroud)

在用Fragment替换内容后,我这样做:

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mDrawerToggle.setDrawerIndicatorEnabled(false);
mActionBar.setDisplayHomeAsUpEnabled(true);
Run Code Online (Sandbox Code Playgroud)

android toolbar android-appcompat android-actionbar android-5.0-lollipop

41
推荐指数
2
解决办法
2万
查看次数

在iOS中需要@ property/@ synthesize的解释

不是一个完整的菜鸟我对iOS编程和Ojbective-C都很陌生.我主要来自C(DSP,微控制器),Delphi XE2/Pascal,Visual Basic和Java(桌面和Android应用程序)的背景.

我主要从Apress的"Beginning iOS 5 Development"一书中学习了Cocoa.

最近我观看了WWDC 2012的视频并浏览了他们的一些示例代码,我必须说我对编写应用程序的正确方法感到困惑,更具体地说是@ property/@ synthesize字.

在本书中,大多数(并非全部)示例代码用于定义属性,例如

ViewController.h
@property (strong, nonatomic) NSMutableArray *list;

ViewController.m
@synthesize list;
Run Code Online (Sandbox Code Playgroud)

然后所有代码访问合成列表

self.list
Run Code Online (Sandbox Code Playgroud)

甚至简单地说

list
Run Code Online (Sandbox Code Playgroud)

现在在我阅读的每个WWDC代码示例中,我看到程序员定义了一个属性,但是在.m文件中他们做了类似的事情

@synthesize list = _list;
Run Code Online (Sandbox Code Playgroud)

并且有时访问

self.list
Run Code Online (Sandbox Code Playgroud)

要么

_list
Run Code Online (Sandbox Code Playgroud)

我很迷惑.什么是正确的做法?由于Apple程序员都使用下划线,我认为我应该这样做,但为什么这本书没有呢?list和_list之间有区别吗?更重要的是,因为我在同一个对象中为什么有时使用self.list,有时候使用list/_list.

有时他们不使用@synthesize,我认为是时候他们想重新编写自己的访问器和mutators(到目前为止我从来都不是这样).

我已经在网上阅读了这些内容,但没有什么能够让我的思路正确,所以我依靠StackOverflow来实现这一点.

最后但并非最不重要的是,我更喜欢并根据当前的iOS 6最佳实践/编程技术进行回答.没用,告诉我如何在旧的iOS中正确地做到这一点.

properties objective-c ios

31
推荐指数
2
解决办法
3万
查看次数

如何在java swing中设置特定的窗口(框架)大小?

我的代码不起作用:

JFrame frame = new JFrame("mull");

mull panel = new mull();

// add panel to the center of window
frame.getContentPane().add("Center", panel);
frame.setSize(500, 300); // << not working!!!
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack(); // give a suitable size to window automatically
frame.setVisible(true); // make window visible
Run Code Online (Sandbox Code Playgroud)

我的窗户越来越小了.怎么解决?

java user-interface swing

30
推荐指数
2
解决办法
16万
查看次数

iOS UItableview scrollToRowAtIndexPath不再工作

今天早上我刚刚安装了包含iOS 6的新Xcode.

我有一个表视图加载了包含章节和行的plist文件.章节定义了各个部分.

用户选择章节和行,并且tableview会自动滚动到正确的位置(在viewDidLoad中).

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:linePos inSection:chapterPos];
[self.tableView scrollToRowAtIndexPath:indexPath 
    atScrollPosition:UITableViewScrollPositionTop animated:YES];
Run Code Online (Sandbox Code Playgroud)

这在iOS5模拟器中效果很好.

在iOS 6模拟器中尝试此操作不会执行滚动.我没有错.我已经检查过,linePos和chapterPos接收到正确的值但是没有执行滚动.

有什么想法吗?

uitableview ios6

19
推荐指数
2
解决办法
3万
查看次数