小编soc*_*oho的帖子

通过命令行自动将Java(Android)项目导入Eclipse工作区

我正在尝试通过命令行(使用bash脚本)自动将项目导入Eclipse工作区.我已经看过许多帖子建议使用CDT无头构建,即使对于非C/C++项目,但我想避免下载CDT,因为我的项目都是Java/Android项目,我希望能够为很多人自动化无需让它们全部下载CDT.我尝试了以下JDT无头构建,但无济于事:

eclipse -nosplash \
    -application org.eclipse.jdt.apt.core.aptBuild \
    -data [absolute_path_to_desired_workspace] \
    -import [absolute_path_to_project_directories]
Run Code Online (Sandbox Code Playgroud)

输出显示"构建工作区"然后"注销",但在工作区中打开Eclipse会话在Package资源管理器中不显示任何内容.

查看工作空间中的./metadata/.log文件似乎没有显示导入的任何错误.

如果不使用CDT无头构建,是否无法自动将现有Java Eclipse项目导入Eclipse?

java eclipse bash scripting android

17
推荐指数
1
解决办法
4761
查看次数

Android TextView和Button并排,ellipsize左侧TextView

我有一个左对齐的TextView和一个右对齐的按钮并排.我希望按钮在右边占用尽可能多的空间(取决于其中的文本),并且左边的文本尽可能多地填充,并在任何溢出时进行椭圆化处理.

|Long title that may or may not ellipsi... <Button with text>|
Run Code Online (Sandbox Code Playgroud)

我已阅读并尝试了许多其他似乎有类似问题的帖子,其中没有一个对我有用.我已经尝试过使用带权重的LinearLayout以及分配了layout_toLeftOf的RelativeLayout,但没有一个是我需要的.

这是我的LinearLayout代码(带有不必要的部分),我给左侧TextView一个layout_weight为1,按钮一个layout_weight为0.这应该给右侧按钮提供所需的所有空间,并给TextView剩下的部分,但相反,左边的标题停止显示,右边的按钮被压到一边并切断.我已经尝试将文本和按钮的宽度替换为0dip,正如我所见,这不会改变任何东西.

<LinearLayout
    android:layout_height="@dimen/title_bar_height"
    android:layout_width="fill_parent"
    android:orientation="horizontal">
  <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:ellipsize="end"
      android:layout_gravity="left|center_vertical"
      android:gravity="left|center_vertical"
      android:textSize="22sp"
      android:lines="1"/>
  <include layout="@layout/action_buttons"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_weight="0"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

将TextView的layout_weight替换为0实际上允许右侧按钮完全适合屏幕,但左侧文本仍未显示.如果我为TextView和按钮将layout_weights设置为0,然后我将TextView的宽度从0dip更改为wrap_content,则所有内容都会显示但是按钮会被压缩以填充剩余空间(并且内部文本被截断).

这是我对RelativeLayout的尝试:

<RelativeLayout
    android:layout_height="@dimen/title_bar_height"
    android:layout_width="wrap_content">
  <include layout="@layout/action_buttons"/>
  <TextView
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_gravity="center_vertical"
      android:layout_alignParentLeft="true"
      android:layout_toLeftOf="@layout/action_buttons"
      android:gravity="center_vertical"
      android:scaleType="center"
      android:textSize="22sp"
      android:ellipsize="end"
      android:lines="1"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

除了左侧TextView(当它太长)重叠并出现在按钮顶部而不是截断和椭圆化时,一切都很好地对齐并显示出来.不应该android:layout_toLeftOf"@ layout/action_buttons"指定TextView应该保持在按钮的左边界?

我试过看似我在这个网站上找到的与此问题有关的一切,但我仍然无法得到解决方案.任何帮助将不胜感激!

android relativelayout android-layout android-linearlayout

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

将 TreeSet 存储在 Hadoop DistributedCache 上

我正在尝试将 a 存储TreeSet在 a 上,DistributedCache以供 Hadoop 映射缩减作业使用。到目前为止,我已经将文件从 HDFS 添加到DistributedCache

Configuration conf = new Configuration();
DistributedCache.addCacheFile(new URI("/my/cache/path"), conf);
Job job = new Job(conf, "my job");
// Proceed with remainder of Hadoop map-reduce job set-up and running
Run Code Online (Sandbox Code Playgroud)

如何有效地将 TreeSet(我已经在此类中构建)添加到我要添加到 DistributedCache 的文件中?我应该使用 Java 的本机序列化以某种方式将其序列化到文件中吗?

请注意,TreeSet 在启动 Map-Reduce 作业的主类中构建一次。TreeSet 永远不会被修改,我只是希望每个映射器都可以只读访问此 TreeSet,而不必一遍又一遍地重建它。

java serialization hadoop mapreduce distributed-cache

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