标签: customizing

如何将搜索栏添加到JSQMessagesViewController

在我的聊天应用程序中,我使用JSQMessagesViewController来呈现对话.该应用程序还有我要搜索的公共消息.我现在尝试使用JSQMessagesViewController显示它们.为此我想隐藏inputToolbar(可以工作)并添加一个搜索栏.

如何使搜索栏可见?当您查看属性topContentAdditionalInset时,它看起来应该是可能的.这是我尝试的代码:

override func viewDidLoad() {
    super.viewDidLoad()

    self.inputToolbar.removeFromSuperview()

    self.searchBar.removeFromSuperview()
    self.topContentAdditionalInset = 44
    self.searchBar.frame = CGRect(x: 0, y: 25, width: 320, height: 44)

    // Attempt 1
    // self.collectionView.addSubview(self.searchBar)

    // Attempt 2
    // self.view.addSubview(self.searchBar)

    // Attempt 3
    // self.navigationController?.navigationBar.addSubview(self.searchBar)

    // Attempt 4
    // self.inputToolbar.addSubview(self.searchBar)

    // Attempt 5
    self.collectionView.superview!.addSubview(self.searchBar)
}
Run Code Online (Sandbox Code Playgroud)

更新:

以下代码似乎可以正常工作.它的问题是: - 它是collectionView的一个子项,因此将滚动显示内容.将其添加到.superview不起作用. - 当搜索栏获得焦点时,它向下滚动44个像素.

var keepRef:JSQMessagesInputToolbar!
var searchBar:UISearchBar!
override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    if self.inputToolbar.superview != nil {
        keepRef = self.inputToolbar
        self.inputToolbar.removeFromSuperview()
    }

    self.topContentAdditionalInset = 44
    if searchBar …
Run Code Online (Sandbox Code Playgroud)

search chat customizing ios jsqmessagesviewcontroller

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

自定义PreferenceScreen的布局

我的要求

注意:我需要支持Android API 15及更高版本.

在我的PreferenceFragment中,我正在将PreferenceScreen动态添加到PreferenceCategory.

PreferenceScreen as = mgr.createPreferenceScreen(context);
as.setTitle(name); 
myCategory.addPreference(as);
Run Code Online (Sandbox Code Playgroud)

当设置活动呈现时,这些PreferenceScreens仅在其行的标题中呈现,请参见下图. PreferenceScreen在设置活动中显示

我想自定义此行中显示的内容.理想情况下,我希望在下面有一个摘要标题,标题/摘要左侧的图标和右侧的某些行上的图标.请参阅下面的模型图像.

期望的我的偏好屏幕的渲染

PreferenceScreen.setWidgetLayoutResource(int widgetLayoutResId)

我知道我可以使用"setWidgetLayoutResource"在我的设置活动中使用以下代码在行布局的右侧添加一个图标(以及带有"setSummary"的摘要)

PreferenceScreen as = mgr.createPreferenceScreen(context);
as.setTitle(name); 
as.setSummary(summary);
as.setWidgetLayoutResource(R.layout.as_widget);
myCategory.addPreference(as);
Run Code Online (Sandbox Code Playgroud)

其中"as_widget.xml"是

<?xml version="1.0" encoding="utf-8"?>
<ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_action_favorite"/>
Run Code Online (Sandbox Code Playgroud)

这将产生如下的UI 使用setWidgetLayoutResource进行布局

这让我更接近我想要的但仍然不完全是我想要的(错过了行开头的图标).

PreferenceScreen.setLayoutResource(int layoutResId)

我相信如果我使用它,那么我可以控制整行的渲染.我在stackoverflow上看过这个例子,比如

根据我的理解,您指定的布局文件必须具有以下内容

  • 它的根视图的id为"@android:id/widget_frame"
  • 一个id为android的视图:id ="@ + android:id/title"(这是放置PreferenceScreen.setTitle中指定的字符串的地方)
  • id为android的视图:id ="@ + android:id/summary"(这是放置PreferenceScreen.setSummary中指定的字符串的位置)

然而,当我尝试这样做时,Android Studio突出显示"@ + android:id/summary",错误为"无法解析符号'@ + android:id/summary'.当应用程序运行时,我的行呈现为完全空白.

我的java是

PreferenceScreen as = mgr.createPreferenceScreen(context);
as.setTitle(name); 
as.setSummary(summary);
as.setLayoutResource(R.layout.as_row_layout);
myCategory.addPreference(as);
Run Code Online (Sandbox Code Playgroud)

我的布局是

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/widget_frame"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:gravity="center_vertical"
    android:paddingRight="?android:attr/scrollbarSize">

    <ImageView
        android:id="@+id/icon1"
        android:src="@drawable/ic_action_email" …
Run Code Online (Sandbox Code Playgroud)

layout android customizing preference preferencescreen

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

自定义OpenFileDialog

我正在使用C#中的winforms应用程序.我想要实现的是从用户获取我正在使用以下代码的文件:

OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
    string sFileName = dlg.FileName;
    //my code goes here
}
Run Code Online (Sandbox Code Playgroud)

现在,一切正常,但我想在同一个对话框中放入3个单选按钮,这意味着我现在可以从这个对话框中得到两个东西

string sFileName = dlg.FileName; //same as in case of traditional dialog box
//some thing like this which tells which radio button is selected:
dlg.rbTypes.Selected
Run Code Online (Sandbox Code Playgroud)

我该如何实现这一目标?

c# openfiledialog customizing winforms

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

屏幕顶部的自定义Toast

请在回答标准例程之前阅读问题以打印Toast :)

我想在屏幕的左上角显示自定义Toast.我使用此代码创建Toast:

    Toast mFixedToast = new Toast(getApplicationContext());
    mFixedToast.setDuration(timeout);
    mFixedToast.setView(myInflatedLayout);
    mFixedToast.setGravity(Gravity.TOP|Gravity.FILL_HORIZONTAL, 0, 0);
    mFixedToast.setMargins(0,0);
Run Code Online (Sandbox Code Playgroud)

然而,在一些设备中,例如三星Galaxy S4,吐司不是位于(0,0),而是具有40-50像素的边缘.许多其他设备按预期工作.

我很肯定WindowManager添加了边距(Toast视图作为TYPE_TOAST类型的视图添加到WindowManager)

这是为什么?可以修改吗?请看下面的代码,我已经将Toast.java克隆到我自己的类中,并隔离了将视图添加到WM的行:

 // LayoutParams for the TOAST view ... tried to change params.type but no luck.
 final WindowManager.LayoutParams params = mParams;
 params.height = WindowManager.LayoutParams.WRAP_CONTENT;
 params.width = WindowManager.LayoutParams.WRAP_CONTENT;
 params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
              | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
              | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
            params.format = PixelFormat.TRANSLUCENT;
 params.windowAnimations = android.R.style.Animation_Toast;
 params.type = WindowManager.LayoutParams.TYPE_TOAST;

 mWM = (WindowManager)mView.getContext().getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
 mParams.gravity = gravity;

 // CHECKED these all are 0 !!!
 mParams.x = mX; mParams.y = …
Run Code Online (Sandbox Code Playgroud)

android customizing layoutparams android-toast

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

UINavigationBar,纯色iOS 5

我正在使用该类别来自定义导航栏.我的代码是:

- (void) drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColor(context, CGColorGetComponents([self.tintColor CGColor]));
    CGContextFillRect(context, rect);
}
Run Code Online (Sandbox Code Playgroud)

它运行良好,但不是在iOS 5中.我需要导航栏颜色是实心的,没有任何渐变.我该怎么做?

据我所知,对于iOS 5,替换drawRect方法的唯一方法是创建一个子类,但有没有办法让所有导航控制器使用UINavigationBar子类而不是原始类?

uinavigationbar customizing ios5

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

如何在Alfresco表单上添加文件上传选择器

如何在Alfresco Share中的表单上添加文件/数据上传选择器?我需要点击我的按钮,然后应该出现文件选择器.有人可以帮忙吗?

components webclient alfresco customizing alfresco-share

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

Wordpress显示the_content抓取错误帖子的内容.为什么?

我的问题是我正在显示"事件"类别中的一些帖子.然后稍后在同一页面上,我想显示一个来自"spiller"类别的随机帖子,并且工作正常.它会随机发布一个帖子,显示标题,缩略图,但是当我说show_content(或the_excerpt)时,它会显示"事件"类别中帖子的所有内容(或摘录).请帮帮我解决这个问题!

<div class="well span6 Padding10">
    <h4 class="titleFont MarginBottom20">KOMMENDE BEGIVENHEDER</h4>
    <?php
    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $args  = array(
        'category_name' => 'events', // Change these category SLUGS to suit your use.
        'paged'         => $paged

    );
    query_posts( $args ); ?>
    <ul>
        <?php
        while ( have_posts() ) : the_post(); ?>
            <li>
                <a href="<?php the_permalink(); ?>"><strong><?php the_title(); ?></strong></a>
            </li>
        <?php endwhile; ?>
    </ul>
</div>

<div class="span6 well" style="height: 250px;"><h4 class="titleFont">SPILLER HIGHLIGHT</h4>
    <div class="row-fluid">
        <?php
        $args       = …
Run Code Online (Sandbox Code Playgroud)

html php wordpress thumbnails customizing

0
推荐指数
1
解决办法
3166
查看次数