小编Rüd*_*ann的帖子

更改ImageView源

ImageView使用以下语法在xml中设置了源图像:

   <ImageView 
      android:id="@+id/articleImg"
      style="@style/articleImgSmall_2"
      android:src="@drawable/default_m" />
Run Code Online (Sandbox Code Playgroud)

现在我需要以编程方式更改此图像.我需要做的是删除旧图像并添加一个新图像.我做的是这样的:

myImgView.setBackgroundResource(R.drawable.monkey);
Run Code Online (Sandbox Code Playgroud)

它工作但我注意到android将新图像堆叠在旧图像之上(不要问我是如何发现它与讨论无关:).在设置新图像之前,我绝对需要摆脱旧版本.

我怎样才能做到这一点?

android imageview android-imageview

239
推荐指数
7
解决办法
27万
查看次数

在SWT中设置颜色

这很简单,我来自swing/awt背景.

我只是想知道为SWT小部件设置背景颜色的正确方法是什么?

我一直在努力:

widget.setBackground( );
Run Code Online (Sandbox Code Playgroud)

除了我不知道如何在SWT中创建颜色对象?

java swt colors

56
推荐指数
3
解决办法
7万
查看次数

EGit中的"自动共享项目位于git存储库"中的含义是什么意思?

每次我导入maven项目.在剩下的任务中,总是出现自动共享git项目(等待).

我在网上挖掘,我只是找到启用/禁用选项的位置,但我想了解正在做什么以及是否需要它.

我一直在做的是在命令行中创建/克隆项目,然后在Eclipse中导入它,然后我可以在EGit中完成所有git工作.

在这种情况下,自动共享项目是否位于git存储库选项中,或者我可以禁用它?

eclipse git maven egit

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

JGit:签出一个远程分支

我正在使用JGit来检查远程跟踪分支.

Git binrepository = cloneCmd.call()

CheckoutCommand checkoutCmd = binrepository.checkout();
checkoutCmd.setName( "origin/" + branchName);
checkoutCmd.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK );
checkoutCmd.setStartPoint( "origin/" + branchName );

Ref ref = checkoutCmd.call();
Run Code Online (Sandbox Code Playgroud)

文件已签出,但HEAD未指向分支.以下是git status输出,

$ git status
# Not currently on any branch.
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)

可以在git命令行中轻松执行相同的操作,它可以正常工作,

git checkout -t origin/mybranch
Run Code Online (Sandbox Code Playgroud)

怎么做这个JGit?

git jgit

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

无法获取状态更改锁定

我们的产品使用最新的生产就绪型SWT,3.7.2.既然当时没有人知道下一个Java版本会被调用(以及他们怎么会知道8之后是8,这就像高等数学一样),我们被迫将org.eclipse.osgi3.7.2 交换到3.10.0,这样我们现在可以支持Java 8.虽然这可能不是最好的想法,但理论上它应该可行.

当然,作为Eclipse Luna的主要搞砸,当我们启动应用程序时会出现这个"错误"(大约50%的时间,我猜):

org.osgi.framework.BundleException: Unable to acquire the state change lock for the module: osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.10.0.v20140606-1445"; singleton:="true" [id=0] STARTED [STARTED] invalid
at org.eclipse.osgi.container.Module.lockStateChange(Module.java:329)
at org.eclipse.osgi.container.SystemModule.init(SystemModule.java:44)
at org.eclipse.osgi.container.SystemModule.start(SystemModule.java:170)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
at org.eclipse.equinox.internal.simpleconfigurator.ConfigApplier.startBundles(ConfigApplier.java:307)
at org.eclipse.equinox.internal.simpleconfigurator.ConfigApplier.install(ConfigApplier.java:108)
at org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorImpl.applyConfiguration(SimpleConfiguratorImpl.java:129)
at org.eclipse.equinox.internal.simpleconfigurator.SimpleConfiguratorImpl.applyConfiguration(SimpleConfiguratorImpl.java:143)
at org.eclipse.equinox.internal.simpleconfigurator.Activator.start(Activator.java:48)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319)
at org.eclipse.osgi.container.Module.doStart(Module.java:571)
at org.eclipse.osgi.container.Module.start(Module.java:439)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
at org.eclipse.osgi.container.SystemModule.startWorker(SystemModule.java:242)
at org.eclipse.osgi.container.Module.doStart(Module.java:571)
at org.eclipse.osgi.container.Module.start(Module.java:439) …
Run Code Online (Sandbox Code Playgroud)

java osgi eclipse-luna

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

Eclipse + Git - 如何获取工具栏?

我已经安装了Eclipse 3.7.2并且工作正常.我安装了git插件(见下文).

我安装的软件

右键单击我的活动项目并单击"团队",我可以选择拉/推/提交等等.

我已将git可执行设置为msysgit(C git).

文档告诉我,要将git添加到我应该查看的工具栏中Window->Customize Perspective...,但我无法在那里找到与git相关的任何内容,甚至在"命令组可用性"部分下也没有.

如何在Eclipse工具栏中添加push,pull和commit按钮?

那里没有Git

eclipse git eclipse-plugin egit

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

getBaseURL()在href =""中的javascript调用函数

我在html页面中通过javascript调用基于URL的URL,我想添加基本URL来调用链接

例如.

<a href="getBaseURL()/filepath/index.html">Page</a>
Run Code Online (Sandbox Code Playgroud)

javascript如下:

function getBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));

    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);

        return baseLocalUrl + "/";
    }
    else {
        // Root Url for domain name
        return baseURL + …
Run Code Online (Sandbox Code Playgroud)

javascript function

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

使用JGit TreeWalk列出文件和文件夹

我想使用JGit显示头版本的所有文件和文件夹的列表.我能够使用TreeWalk列出所有文件,但这不会列出文件夹.

这是我到目前为止:

public class MainClass {

    public static void main(String[] args) throws IOException {
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Repository repository = builder
                .setGitDir(new File("C:\\temp\\git\\.git")).readEnvironment()
                .findGitDir().build();

        listRepositoryContents(repository);

        repository.close();
    }

    private static void listRepositoryContents(Repository repository) throws IOException {
        Ref head = repository.getRef("HEAD");

        // a RevWalk allows to walk over commits based on some filtering that is defined
        RevWalk walk = new RevWalk(repository);

        RevCommit commit = walk.parseCommit(head.getObjectId());
        RevTree tree = commit.getTree();
        System.out.println("Having tree: " + tree);

        // now use a TreeWalk to …
Run Code Online (Sandbox Code Playgroud)

java jgit

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

Eclipse EGit命令行

我最近安装了Git for Eclipse(EGit),我通过右键单击 - >团队 - >添加/提交/删除/排除/等使用了一些基本功能.

但是,我想使用git和命令行语法的一些更复杂的功能.有没有办法在Eclipse中执行此操作或在命令行中设置EGit?

eclipse git egit

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

使用JGit键可以安全地访问Git存储库

我正在使用JGit访问远程Git仓库,我需要使用SSH.JGit使用JSch提供安全访问.但是,我不确定如何为JGit设置密钥文件和已知的hosts文件.我试过的内容如下.

使用子类化JSchConfigSessionFactory创建SshSessionFactory的自定义配置:

public class CustomJschConfigSessionFactory extends JschConfigSessionFactory {
    @Override
    protected void configure(OpenSshConfig.Host host, Session session) {
        session.setConfig("StrictHostKeyChecking", "yes");
    }
}
Run Code Online (Sandbox Code Playgroud)

在我访问远程Git仓库的类中,执行以下操作:

CustomJschConfigSessionFactory jschConfigSessionFactory = new CustomJschConfigSessionFactory();

JSch jsch = new JSch();
try {
    jsch.addIdentity(".ssh/id_rsa");
    jsch.setKnownHosts(".ssh/known_hosts");
} catch (JSchException e) {
    e.printStackTrace();  
}
    SshSessionFactory.setInstance(jschConfigSessionFactory);
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何将此JSch对象与JGit关联,以便它可以成功连接到远程存储库.当我尝试使用JGit克隆它时,我得到以下异常:

org.eclipse.jgit.api.errors.TransportException: git@git.test.com:abc.org/test_repo.git: reject HostKey: git.test.com
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
at GitTest.cloneRepo(GitTest.java:109)
at GitTest.main(GitTest.java:223)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) …
Run Code Online (Sandbox Code Playgroud)

java git ssh jsch jgit

13
推荐指数
3
解决办法
1万
查看次数