小编sab*_*dow的帖子

如何使用嵌套片段在AndroidPager中添加片段(Android 4.2)

我有ViewPager三个Fragments,每个显示一个List(或Grid).

在新的Android API level 17(Jelly Bean 4.2)中,其中一个功能是嵌套片段.新功能描述说:

如果您使用ViewPager创建左右滑动并占用大部分屏幕空间的片段,则现在可以将片段插入到每个片段页面中.

所以,如果我理解正确的话,现在我可以在里面创建一个ViewPagerwith Fragments(里面有一个按钮),当用户按下按钮时显示另一个Fragment没有松动ViewPager使用这个新功能.

我已经花了我的早上尝试实现这几种不同的方式,但我不能让它工作......有人可以添加一个如何实现这个的简单示例吗?

PS:我只对这种方式感兴趣,getChildFragmentManager学习如何运作.

android android-fragments android-viewpager android-support-library android-nested-fragment

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

我应该使用哪个Apple推送通知服务Java库?

我需要使用Apple推送通知服务(APNS)从我的Java服务器向iOS设备发送推送通知

我找到了两个用Java发送APNS推送通知的库:

  1. Java的APNS
  2. javapns

但两者似乎都被放弃了(或者至少他们有错误,最后一个版本是一年前).

java-apns有很多分叉.在积极开发中是否有这个库的更新分支?还有其他更好的选择吗?

java apple-push-notifications ios

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

使用ADT 20将Maven Android Android项目导入Eclipse时出错

我将ADT插件更新到最新版本(20)和android-sdk工具.现在,当我尝试将现有的Android Maven导入Eclipse时引发异常An internal error occurred during: "Importing Maven projects". com/android/io/StreamException,并创建eclipse项目但不像以前那样像Android项目.以前在工作区中存在的(maven android)项目工作正常.

导入项目时的Eclipse完整异常跟踪如下:

!ENTRY org.eclipse.osgi 2 1 2012-06-29 19:02:34.421
!MESSAGE NLS unused message: LifecycleMappingPropertyPage_this_message in: org.eclipse.m2e.core.ui.internal.messages

!ENTRY org.eclipse.core.jobs 4 2 2012-06-29 19:03:03.953
!MESSAGE An internal error occurred during: "Importing Maven projects".
!STACK 0
java.lang.NoClassDefFoundError: com/android/io/StreamException
    at me.gladwell.eclipse.m2e.android.project.EclipseAndroidProjectFactory.createAndroidProject(EclipseAndroidProjectFactory.java:17)
    at me.gladwell.eclipse.m2e.android.project.EclipseAndroidProjectFactory.createAndroidProject(EclipseAndroidProjectFactory.java:1)
    at me.gladwell.eclipse.m2e.android.AndroidMavenProjectConfigurator.configure(AndroidMavenProjectConfigurator.java:62)
    at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:109)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:414)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProject(ProjectConfigurationManager.java:240)
    at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:156)
    at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$1.doCreateMavenProjects(MavenImportWizard.java:164)
    at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:73)
    at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$3.runInWorkspace(MavenImportWizard.java:249)
    at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.ClassNotFoundException: com.android.io.StreamException
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) …
Run Code Online (Sandbox Code Playgroud)

eclipse android adt maven

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

ImageView适合不拉伸图像

是否有可能我的ImageView所有屏幕尺寸都适合没有图像看起来拉伸?

我尝试使用fill_parent> 将所有比例类型更改为背景和srcwrap_content

但仍然.如果图像不小,它只是看起来拉伸..

例:

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="centerInside"
    android:adjustViewBounds="true"
    android:background="@drawable/background" />

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scaleType="fitXY"
    android:adjustViewBounds="true"
    android:background="@drawable/background" />
Run Code Online (Sandbox Code Playgroud)

这两个适合宽度,但图像被拉伸..但当我将其更改为src时,图像只是居中和小.

android uiimageview imageview android-layout

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

在服务器端使用url hash获取当前页面的完整URL

我无法得到我正在处理的页面的完整网址.这是我想要获取的网址http://localhost:54570/Shipment/ShipmentDetails.aspx?HawbBLNo=NEC00000004#BFT结果仅适用http://local/Shipment/ShipmentDetails.aspx?HawbBLNo=NEC00000004于此代码

protected void btnSave_Click(object sender, EventArgs e)
{
    url = HttpContext.Current.Request.Url.AbsoluteUri;
    UpdateDetails();
    Response.Redirect(url);
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net url

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

在java中解密时出错

我正在尝试用Java加密/解密String.没有关于加密的问题然后存储在sqlite表中.但我总是得到同样的错误试图解密它:

"java.security.InvalidKeyException:当预期时没有设置IV"

这是我的代码片段:

public String encrypt(String password){
    try
    {
        String key = "mysecretpassword";
        SecretKeySpec keySpec = null;
        keySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
        cipher.init(Cipher.ENCRYPT_MODE, keySpec);
        return new String(cipher.doFinal(password.getBytes()));
    }
    catch (Exception e)
    {
        return null;
    }
}

public String decrypt(String password){
    try
    {
        String key = "mysecretpassword";
        SecretKeySpec keySpec = null;
        keySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
        cipher.init(Cipher.DECRYPT_MODE,keySpec);
        return new String(cipher.doFinal(password.getBytes()));
    }
    catch (Exception e)
    {
        System.out.println(e);
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

java sqlite encryption android

8
推荐指数
1
解决办法
3400
查看次数

Android - 在外部浏览器中打开网址会导致无限循环

我的应用程序可以默认打开链接:

<category android:name="android.intent.category.BROWSABLE" />
    <data
        android:host="example.com"    
        android:scheme="http" />
    <data
        android:host="www.example.com"
        android:scheme="http" />
             ....
Run Code Online (Sandbox Code Playgroud)

现在,我的应用程序中有一个我不支持的链接.所以我在同时做的是用外部浏览器打开它.像这样:

String requestURL = "www.example.com/unsupportedlink";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(requestURL));
mActivity.startActivity(i);
Run Code Online (Sandbox Code Playgroud)

我期望它会在浏览器上打开,但是如果用户选择默认情况下应用程序打开所有链接("Allways open"而不是"Just Once"),则再次调用app并发送链接再次访问浏览器 - 它会导致无限循环.我怎么能避免这个?

android android-intent

8
推荐指数
1
解决办法
666
查看次数

Android系统.自定义意图选择器

我想知道,有没有办法选择使用Intent.createChooser方法的行为?例如,我有一个图像,我想通过电子邮件发送,如果它被选中(第一个选项).在第二个选项,我想发送sms此图像上的链接(为此我需要复杂的操作 - 上传图像到服务器,检索下载链接,我想在其中sms,并将其粘贴到sms)

你能否提出任何建议,我该怎样做才能完成第二项任务?

我相信我可以发送带有这样的图像的电子邮件:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{textMail}); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Some Subj"); 
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Some Extra Text"); 
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileUri));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Run Code Online (Sandbox Code Playgroud)

UPD:我意识到,我真正需要的是拦截用户点击,如果sms是在意图选择器中选择的话.那么,问题是如何实现它?

android android-intent

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

我的应用程序使用AccessibilityManager未处理的事件使设备崩溃(Galaxy Nexus和Nexus 4)

当我在我的Galaxy Nexus上切换到4.2并且持续使用我的Nexus 4时,这种情况就开始发生了.我的应用程序随机崩溃(软复位)设备,即使没有用户输入也是如此.

这是崩溃前的Logcat:

01-17 12:54:24.960: E/AccessibilityManager(10497): Error during sending EventType: TYPE_WINDOW_CONTENT_CHANGED; EventTime: 151405384; PackageName: com.ntasher.homeconII; MovementGranularity: 0; Action: 0 [ ClassName: android.widget.FrameLayout; Text: []; ContentDescription: null; ItemCount: -1; CurrentItemIndex: -1; IsEnabled: true; IsPassword: false; IsChecked: false; IsFullScreen: false; Scrollable: false; BeforeText: null; FromIndex: -1; ToIndex: -1; ScrollX: -1; ScrollY: -1; MaxScrollX: -1; MaxScrollY: -1; AddedCount: -1; RemovedCount: -1; ParcelableData: null ]; recordCount: 0 
01-17 12:54:24.960: E/AccessibilityManager(10497): android.os.DeadObjectException
01-17 12:54:24.960: E/AccessibilityManager(10497):  at android.os.BinderProxy.transact(Native Method)
01-17 12:54:24.960: E/AccessibilityManager(10497):  at android.view.accessibility.IAccessibilityManager$Stub$Proxy.sendAccessibilityEvent(IAccessibilityManager.java:227)
01-17 …
Run Code Online (Sandbox Code Playgroud)

android

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

我可以使用fabric sdk在我的时间轴上设置自定义onClick吗?

我正在使用Fabric创建一个Twitter客户端,但我无法创建自定义onClick.我创建了这个自定义适配器,并尝试创建一个OnClickListener但不起作用.始终在浏览器推文中打开.

public class TweetAdapter extends TweetTimelineListAdapter {

    public ArrayList<Long> tweetIds=new ArrayList<Long>();
    public TweetAdapter(Context context, Timeline<Tweet> timeline) {
        super(context, timeline);
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Object rowView = convertView;
        final Tweet tweet = (Tweet)this.getItem(position);
        if(convertView == null) {
            rowView = new CompactTweetView(this.context, tweet);
        } else {
            ((BaseTweetView)convertView).setTweet(tweet);
            ((View)rowView).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    tweetIds.add(tweet.getId());
                }
            });
        }
        return (View)rowView;
    }
}
Run Code Online (Sandbox Code Playgroud)

在BaseTweetView类中,它是函数类型OnClickListener,但在这种情况下,我想不出有任何想法要覆盖.

private void setPermalinkLauncher() {
    BaseTweetView.PermalinkClickListener listener = new BaseTweetView.PermalinkClickListener();
    this.setOnClickListener(listener); …
Run Code Online (Sandbox Code Playgroud)

twitter onclick android-listview android-adapter twitter-fabric

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