小编Ava*_*i Y的帖子

Android:如何从日期和时间选择器中获取值

我建立一个应用程序中,我试图让用户选择的时间,所以我用datePickertimePickerbutton set.所以,当他点击set button一个dialog box并且说你已经选择了x日期和x时间或者以任何方式消息应该出现在屏幕上,就像用户选择了这个时间一样.所以,我建立了代码,但作为我的应用程序来该活动总是得到有力stopped.There与没有问题xml file有关,因为当我从评论提取值的java的线来显示数据datePickertimePicker,应用作品精绝.我仍然发布两个文件代码,以便于理解.还发布了日志猫异常.我删除了所有不必要的代码,如导入和包以及额外的按钮等,以使其快速可读.

这是.xml文件代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="10"
android:id="@+id/commonlayout" android:background="#FFFFFF">

<LinearLayout android:id="@+id/llheader"
    android:layout_width="fill_parent" android:layout_height="20dp"
     android:layout_weight="1"
     android:background="@drawable/bg">

    <RelativeLayout android:id="@+id/relativeLayout1"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_gravity="center"> <!--header-->
        <TextView
            android:id="@+id/txt_header"
            android:layout_width="wrap_content"          
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"/>            
        </RelativeLayout>           
</LinearLayout>
 <ScrollView 
    android:id="@+id/scrollView1"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="wrap_content"
    android:id="@+id/linearLayout1" android:orientation="vertical"
    android:layout_height="wrap_content" 
<DatePicker android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
  android:id="@+id/datePicker"></DatePicker>
<TimePicker android:id="@+id/timePicker"
    android:layout_width="wrap_content"   
  android:layout_height="wrap_content</TimePicker>
<TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content"
    android:layout_width="match_parent" android:gravity="center">

    <Button android:id="@+id/btnSetDateTime"
        android:layout_height="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

java time android date datepicker

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

Android - 禁用设备返回按钮

我正在使用PhoneGap处理android应用程序.我需要使用以下代码处理设备后退按钮功能:

 import com.phonegap.DroidGap;
 public Class MyClass extends DroidGap {
 appView.setOnKeyListener(new OnKeyListener() { 
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                finish();
                return true;
            }
            return onKeyDown(keyCode, event); 
        } 
    });
  }
Run Code Online (Sandbox Code Playgroud)

通过使用上面的代码,应用程序退出,因为我已经使用finish();但我想什么都不应该发生在点击设备后退按钮.我怎么能实现这一点?请帮我.

android back-button cordova

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

Android RelativeLayout对齐关注

我正在玩Android布局并尝试进行简单的QA测试,但我无法正确布局.我只是不知道如何调整这些东西,经过几个小时的战斗,我需要一些帮助.

这就是我想要的:

在此输入图像描述

我得到了什么:

在此输入图像描述

这是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >

    <RelativeLayout
        android:id="@+id/nodeLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/textQuestion"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:text="TextView"
            android:textSize="18dp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:orientation="vertical" >

            <RadioGroup
                android:id="@+id/radioAnswersGroup"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </RadioGroup>

            <LinearLayout
                android:id="@+id/questionsNavigationGroup"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:orientation="horizontal" >

                <Button
                    android:id="@+id/buttonPreviousQuestion"
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:layout_weight="1"
                    android:background="@drawable/fancy_button"
                    android:gravity="center|center_vertical"
                    android:onClick="onPreviousQuestionButtonClick"
                    android:shadowColor="#fff"
                    android:shadowRadius="3"
                    android:text="Back"
                    android:textColor="#432f11"
                    android:textSize="24dp" />

                <Button
                    android:id="@+id/buttonNextQuestion"
                    android:layout_width="match_parent"
                    android:layout_height="45dp"
                    android:layout_weight="1"
                    android:background="@drawable/fancy_button"
                    android:gravity="center|center_vertical"
                    android:onClick="onNextQuestionButtonClick"
                    android:shadowColor="#fff"
                    android:shadowRadius="3"
                    android:text="Next"
                    android:textColor="#432f11"
                    android:textSize="24dp" />

                <Spinner …
Run Code Online (Sandbox Code Playgroud)

layout android scrollview relativelayout

6
推荐指数
1
解决办法
1816
查看次数

Java - 将doc/docx文件转换为chm文件

我有一个想法将Word文档(.doc/.docx)文件转换为帮助文件(.chm)格式.我想用Java来转换文件.我的公式很简单.要在Word文档中创建目录页面和其他链接,作为包浏览器或文件浏览器,使用户导航更简单,更快速,更容易在文档中的页面之间导航.

所以,我的问题是:

java中是否有可以导入并用于文件转换的本机库?

请分享您的想法以实现上述概念.

java chm doc docx

6
推荐指数
1
解决办法
1620
查看次数

如何在Google Map V2中的标记中偏移气球视图?

单击标记时,会出现一个气球.但是在标记和气球之间有太大的空间,所以我怎么能减少这个距离?这就像使用中的setBalloonBottomOffset方法V1 Google Map.

custom balloon是这堂课:

public class CustomInfoWindowAdapter implements InfoWindowAdapter {

    private final View mWindow;
    private final View mContents;

    public CustomInfoWindowAdapter(Activity activity) {
        LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mWindow = inflater.inflate(R.layout.ballon, null);
        mContents = inflater.inflate(R.layout.ballon, null);
    }

    @Override
    public View getInfoWindow(Marker marker) {
        render(marker, mWindow);
        return mWindow;
    }

    @Override
    public View getInfoContents(Marker marker) {
        render(marker, mContents);
        return mContents;
    }

    private void render(Marker marker, View view) {
        String title = marker.getTitle();
        TextView titleUi = ((TextView) …
Run Code Online (Sandbox Code Playgroud)

android android-maps-v2

6
推荐指数
1
解决办法
3057
查看次数

JNI加载:警告:不要硬编码使用Context.getFilesDir().getPath()代替

我在我的一个应用程序中遇到问题,我有以下代码加载应用程序所需的lib(JNI):

static {
    // load the JNI library
    Log.i("JNI", "loading JNI library...");
    System.load("/data/data/com.mypackage.appname/lib/libxxxxxx.so");
    Log.i("JNI", "JNI library loaded!");
}
Run Code Online (Sandbox Code Playgroud)

所以我得到了警告:"Do note hardcode use Context.getFilesDir().getPath() instead"这是完全正确的(它不会在每台设备上都可移植).问题是,因为我使用静态我无法呼唤Context.getFilesDir().getPath().

你有什么想法我可以继续这样做吗?

java-native-interface android warnings

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

Android - 如何在Swipe上移动ImageView

我是新手,为Android应用程序实现Swipe Gesture.我正在尝试使用以下代码从屏幕的左侧向右侧滑动ImageView:

 public class MainActivity extends Activity implements OnClickListener{
private static final int SWIPE_MIN_DISTANCE = 10;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private GestureDetector gestureDetector;
View.OnTouchListener gestureListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ImageView btnSwipe = (ImageView)findViewById(R.id.imgBtnSwipe);
    btnSwipe.setOnClickListener(this);
    gestureDetector = new GestureDetector(this, new MyGestureDetector());
    gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    };
    btnSwipe.setOnTouchListener(gestureListener);
}
class MyGestureDetector extends SimpleOnGestureListener {
    @Override
    public boolean …
Run Code Online (Sandbox Code Playgroud)

java android swipe

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

没有预定义宽度的响应式砌体布局

我正在使用不同尺寸的图像创建2列砌体布局.图像可以是任何大小,只要它们具有最大公约数(根据Masonry插件的要求).

为了使布局响应我将砌体项目的宽度转换为百分比(或者我可以使用最小宽度和宽度100%).

更新:我注意到许多人回答这两个列作为解决方案的50%.这有效但不是目标.图像必须保留其原始图像大小.它们可以缩小但保持相同的比例.

$(function () {    
    var container = $('#container');

    // Convert .box width from pixels to percent
    $('.box').find('img').each(function () {
        var percent = ($(this).width()) / container.width() * 100 //convert to percent;
        $(this).closest('.box').css('max-width', percent + '%');
    });

    // Trigger masonry
    container.masonry({
        itemSelector: '.box',
        columnWidth: 1 //widths dividable by 1
    });
});
Run Code Online (Sandbox Code Playgroud)

jsfiffle:http://jsfiddle.net/AMLqg/278/

这似乎有效.调整窗口大小时,项目是流动的.但是,如果以小窗口大小(小于2列宽度)加载脚本,则项目会崩溃.即使窗口较小,如何保持砌体物品对窗口负载的响应?

更新:这是更多信息,以便更好地理解.无论窗口大小如何,我都试图保留2个响应列.列不能具有相等的宽度,因为图像具有不同的宽度.出于这个原因我正在使用,columnWidth: 1因为所有宽度都可以分为1.

请参阅下面的图片以获取示例.

问题:在小窗口中打开页面时,元素将折叠.当您将窗口的大小调整为更大时,元素将保持折叠状态,直到窗口宽度大于两个元素的宽度.

在此输入图像描述

目标:我正在尝试将元素保存在2个响应列中,如下图所示.目前它们仍然保持响应,如果在加载时窗口很大并且你将其调整为较小但不反之亦然当窗口负载较小并且你使其变大时.

在此输入图像描述

javascript css jquery jquery-masonry masonry

6
推荐指数
1
解决办法
6055
查看次数

在android中加入表

我的sqllite数据库中有3个表,其中两个是配置表,另一个是存储数据的主表.现在如何通过连接android中的2个表,如何以及在何处执行连接操作来从主表中检索数据.

任何人都可以指导我.

sqlite android

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

设置土耳其语文本转语音

我正在开发文本到语音应用程序,我想将土耳其语设置为这样:

tts.setLanguage(Locale.TR);
Run Code Online (Sandbox Code Playgroud)

但这在android中不可用,这种添加方式是错误的还是有不同的方法将土耳其语添加到文本到语音中。

任何帮助和建议将不胜感激

文本转语音代码:

 public class AndroidTextToSpeechActivity extends Activity implements
    TextToSpeech.OnInitListener {
/** Called when the activity is first created. */

private TextToSpeech tts;
private Button btnSpeak;
private EditText txtText;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tts = new TextToSpeech(this, this);

    btnSpeak = (Button) findViewById(R.id.btnSpeak);

    txtText = (EditText) findViewById(R.id.txtText);

    // button on click event
    btnSpeak.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            speakOut();}  
                       });}
@Override
public void onDestroy() {
    // Don't forget to shutdown!
    if (tts …
Run Code Online (Sandbox Code Playgroud)

android text-to-speech

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