resources

Android ImageButton - determine what resource is currently set

北慕城南 提交于 2019-12-29 07:31:57
问题 Is there a way I can find what resource a particular ImageButton is set to, at any given time? For eg: I have an ImageButton that I set to R.drawable.btn_on onCreate. Later, at some point, the ImageButton gets set to R.drawable.btn_off . I want to be able to check what resource the ImageButton is set to in my code. Thanks Chris 回答1: Just use setTag() and getTag() to associate and retrieve custom data for your ImageView . 回答2: You could define your own class as a child of ImageButton , add a

Maven overwrite resource file in dependency

五迷三道 提交于 2019-12-29 05:25:15
问题 I have two Maven modules, A and B . A is a dependency of B . Both modules have a resource file named default.properties located in src/main/resources . I need to keep the filenames the same and the location of the file the same in both projects because both A and B are using code which expects the file to be named and located where it is. When building B , A 's default properties is in the final jar . I wish to have B 's properties when I build B . How can I do this? 回答1: Ok, Maven Resources

How to use an DLL load from Embed Resource?

纵饮孤独 提交于 2019-12-29 05:20:48
问题 I have a DLL >> System.Data.SQLite.dll To use it in a normal way > just add it as reference and using System.Data.SQLite; then, I can use all the functions inside this DLL. But , I want to merge my app.exe and this DLL into one single file. I have tried using ILmerge , but fail. As I know, ILmerge cannot merge unmanage DLL. So, I tried another method > make the DLL as embbed resource. I am able to load it as an assembly with the below code: Stream stm = Assembly.GetExecutingAssembly()

List all embedded resources in a folder

♀尐吖头ヾ 提交于 2019-12-29 03:50:29
问题 In my solution a had a folder with a few files. All this files have the Build Action "Embedded Resource". With this code I can get a file: assembly.GetManifestResourceStream(assembly.GetName().Name + ".Folder.File.txt"); But is there any way to get all *.txt files in this folder? A list of names or a method to iterate through them all? 回答1: You could check out assembly.GetManifestResourceNames() which returns an array of strings of all the resources contained. You could then filter that list

How can I detect which layout is selected by Android in my application?

独自空忆成欢 提交于 2019-12-29 02:21:38
问题 Assume I have an activity with three different layouts in different resource folders. For example: layout-land/my_act.xml layout-xlarge/my_act.xml layout-xlarge-land/my_act.xml In different devices and different positions one of them is selected by Android. How can I find out which one is selected programmatically ? Does Android have any API that returns these layouts to the program? Edit : Graham Borland's solution has a problem in some situations that I mentioned in the comments. 回答1: You

Jar get image as resource

﹥>﹥吖頭↗ 提交于 2019-12-29 01:50:10
问题 I'm trying to get load an image from my jar. But no matter what string I supply for getResource() it always returns null. try { System.out.println(Bootstrapper.class.getResource("./img/logo.png").toURI().getPath()); } catch (URISyntaxException ex) { Logger.getLogger(CrawlerFrame.class.getName()).log(Level.SEVERE, null, ex); } ImageIcon ii = new ImageIcon(Bootstrapper.class.getResource("./img/logo.png")); setIconImage(ii.getImage()); Exception in thread "AWT-EventQueue-0" java.lang

Automatically change drawer language when app resume from backstack

为君一笑 提交于 2019-12-29 01:26:19
问题 I have implemented two language in my app "English" and "French" and both of them are working fine individually. When I am trying to check the language change with device language that time getting problem. Recently my app and device language are "French". Now I am changing the device language from "French" to "English" and then open the app from backstack, app language is still in "French" thats right but In the app, navigation drawer related content changed to "English" Below is the code

Version resource in DLL not visible with right-click

谁说我不能喝 提交于 2019-12-28 15:26:39
问题 I'm trying to do something which is very easy to do in the regular MSVC, but not supported easily in VC++ Express. There is no resource editor in VC++ Express. So I added a file named version.rc into my DLL project. The file has the below content, which is compiled by the resource compiler and added to the final DLL. This resource is viewable in the DLL using reshacker, though not when right-clicking the DLL in Windows Explorer. What is missing from my RC file to make it appear when right

Version resource in DLL not visible with right-click

丶灬走出姿态 提交于 2019-12-28 15:25:05
问题 I'm trying to do something which is very easy to do in the regular MSVC, but not supported easily in VC++ Express. There is no resource editor in VC++ Express. So I added a file named version.rc into my DLL project. The file has the below content, which is compiled by the resource compiler and added to the final DLL. This resource is viewable in the DLL using reshacker, though not when right-clicking the DLL in Windows Explorer. What is missing from my RC file to make it appear when right

Why can't I use resources as ErrorMessage with DataAnnotations?

夙愿已清 提交于 2019-12-28 05:38:05
问题 Why can't I do like this? [Required(ErrorMessage = "*")] [RegularExpression("^[a-zA-Z0-9_]*$", ErrorMessage = Resources.RegistrationModel.UsernameError)] public string Username { get; set; } What is the error message telling me? An attribute argument must be a constant expression , typeof expression or array creation expression of an attribute parameter type. 回答1: When you are using the ErrorMessage property only constant strings or string literal can be assigned to it. Use the