据我所知,在Windows Phone 7的Silverlight中没有默认的输入对话框.但我需要这个用于我的项目.
我希望它具有与默认消息框类相同的地铁外观.这是最简单的方法吗?我可以扩展messagebox类并添加som类型的文本字段吗?或者我应该使用弹出窗口还是子窗口?
请帮助我解决这个问题:)堆栈溢出是一个很好的资产,并且当我陷入我的项目时帮助了我很多!
我试图在我的扩展工具栏中设置我的后导航图标的位置,如下所示:
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
app:theme="@style/Toolbar"
android:minHeight="@dimen/action_bar_height"
app:buttonGravity="top"
android:gravity="top"
android:background="?attr/colorPrimary" />
Run Code Online (Sandbox Code Playgroud)
检查工具栏的来源,我们可以看到以下内容:
private void ensureNavButtonView() {
if (mNavButtonView == null) {
mNavButtonView = new ImageButton(getContext(), null,
R.attr.toolbarNavigationButtonStyle);
final LayoutParams lp = generateDefaultLayoutParams();
lp.gravity = GravityCompat.START | (mButtonGravity & Gravity.VERTICAL_GRAVITY_MASK);
mNavButtonView.setLayoutParams(lp);
}
}
Run Code Online (Sandbox Code Playgroud)
mButtonGravity通过哪里分配
mButtonGravity = a.getInteger(R.styleable.Toolbar_buttonGravity, Gravity.TOP);
Run Code Online (Sandbox Code Playgroud)
因此,Gravity.TOP如果没有配置,我的工具栏的重力应该已经正确读取.但它看起来像这样:

android android-layout android-support-library android-toolbar
我是rx-java和rx-android的完全初学者.我听说学习曲线一开始就很陡峭.
我试图通过使用rx-android将所有基于Eventbus的代码替换为更安全的替代方案.
我已经设置了这个片段来编辑文本文本更改事件中的observable:
主要活动
RxUtils.createEditTextChangeObservable(txtInput).throttleLast(200, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()).subscribe(new Action1<EditText>() {
@Override
public void call(EditText editText) {
searchStopResultFragment.query(editText.getText().toString());
}
});
Run Code Online (Sandbox Code Playgroud)
RxUtils:
public static Observable<EditText> createEditTextChangeObservable(final EditText editText){
return Observable.create(new Observable.OnSubscribe<EditText>() {
@Override
public void call(final Subscriber<? super EditText> subscriber) {
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (subscriber.isUnsubscribed()) return;
subscriber.onNext(editText);
}
});
} …Run Code Online (Sandbox Code Playgroud) 我在http://forums.create.msdn.com找到了这个Pinch-to-zoom示例
这是xaml:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<TextBlock Text="Tap to center" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Tap and hold to reset" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Touch and move to drag" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Pinch (touch with two fingers) to scale and rotate" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
<TextBlock Text="Flick (drag and release the touch while still moving) will show flick data on bottom of screen." Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
</StackPanel>
<TextBlock x:Name="flickData" Text="Flick:" Style="{StaticResource PhoneTextNormalStyle}" VerticalAlignment="Bottom"/>
<Image x:Name="image" Source="/map.jpg" RenderTransformOrigin="0.5,0.5" CacheMode="BitmapCache">
<Image.RenderTransform>
<CompositeTransform x:Name="transform"/> …Run Code Online (Sandbox Code Playgroud) 我在我的网站上有这些元素,它们是动态添加到jQuery的document.ready功能上的.
问题是我不能使用常规的jQuery选择器来选择那些元素.JavaScript在IE9和其他浏览器中运行良好.我认为它不起作用的原因是因为我试图改变的内容是动态添加的.
我该如何解决这个问题?
码:
$('.dynamic').each(function(index)
{
$('textarea, input[type=radio], input[type=checkbox], select, input[type=text]', this).each(function()
{
var array = $(this).val().split('|||');
var elements = new Array();
var target = String('.dynamic_'+$(this).attr('id'));
$(target).each(function() //this does nothing in ie7 and 8, seems the target selector is messed up :S
{
elements.push($(this));
});
for (val in array)
{
var count = Number(val);
$(elements[count]).val(array[val]);
}
});
});
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个自定义适配器实现.我在这个适配器中也有一些不同的视图类型.
我需要在运行时替换我的适配器的一些视图.Romain Guy说"......动态更改视图类型计数,这是一个很大的错误"(请参阅ArrayAdapter和ListView - ArrayIndexOutOfBoundsException).当视图类型计数动态变化时,这样做的正确方法是什么?
AdapterCode:
...
private List<Class<?>> itemTypes = new ArrayList<Class<?>>(20);
private void initList(List<Object> items) {
itemTypes = new ArrayList<Class<?>>(20);
positionSection = new SparseArray<Integer>(items.size());
int count = 0;
int sectionIndex = -1;
for (Object object : items) {
Class<?> currentClass = object.getClass();
if (object instanceof String) {
sectionIndex = count;
}
if (!itemTypes.contains(currentClass)) {
itemTypes.add(currentClass);
}
positionSection.put(count, sectionIndex);
count++;
}
}
@Override
public int getItemViewType(int position) {
return itemTypes.indexOf(items.get(position).getClass());
}
@Override
public int getViewTypeCount() {
int …Run Code Online (Sandbox Code Playgroud) android android-listview android-adapter android-adapterview
我正在使用wagtail作为网站的REST后端。该网站是使用React构建的,并通过Wagtails API v2获取数据。
SPA网站必须能够显示w的页面预览。我的想法是serve_preview在页面模型上重写,然后简单地将新页面序列化为JSON并将其写入到可由前端访问的缓存中。但是我在将我的页面序列化为json时遇到麻烦。所有尝试都感觉很“骇人”
我已经尝试过使用序列化程序中内置的w的扩展名,但是没有成功:
豁免1:
def serve_preview(self, request, mode_name):
from wagtail.api.v2.endpoints import PagesAPIEndpoint
endpoint = PagesAPIEndpoint()
setattr(request, 'wagtailapi_router',
WagtailAPIRouter('wagtailapi_v2'))
endpoint.request = request
endpoint.action = None
endpoint.kwargs = {'slug': self.slug, 'pk': self.pk}
endpoint.lookup_field = 'pk'
serializer = endpoint.get_serializer(self)
Run Code Online (Sandbox Code Playgroud)
觉得在这里使用路由器并设置一堆attrs非常丑陋
尝试2:
def serve_preview(self, request, mode_name):
from wagtail.api.v2.endpoints import PagesAPIEndpoint
fields = PagesAPIEndpoint.get_available_fields(self)
if hasattr(self, 'api_fields'):
fields.extend(self.api_fields)
serializer_class = get_serializer_class(
type(self), fields, meta_fields=[PagesAPIEndpoint.meta_fields], base=PageSerializer)
serializer = serializer_class(self)
Run Code Online (Sandbox Code Playgroud)
更好,但我遇到了上下文问题:
Traceback (most recent call last):
...
File "/usr/local/lib/python3.5/site-packages/wagtail/api/v2/serializers.py", line 92, in to_representation …Run Code Online (Sandbox Code Playgroud) 我有一个场景,我需要定期调用API来检查结果.我正在Flowable.interval创建一个调用API的区间函数.
但是,我在背压方面遇到了麻烦.在下面的示例中,在区间中的每个刻度上创建一个新单.如果呼叫尚未进行,则所需的效果是仅调用API
Flowable.interval(1, 1, TimeUnit.SECONDS).flatMap {
System.out.println("Delay $it")
//simulates API call
Single.just(1L).doAfterSuccess {
System.out.println("NEW SINGLE!!!")
}.delay(4, TimeUnit.SECONDS).doAfterSuccess {
System.out.println("SINGLE SUCCESS!!!")
}.toFlowable()
}.subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()).blockingFirst()
Run Code Online (Sandbox Code Playgroud)
我可以使用像这样的过滤变量来解决这个问题:
var filter = true
Flowable.interval(1, 1, TimeUnit.SECONDS).filter {
filter
}.flatMap {
System.out.println("Delay $it")
Single.just(1L).doOnSubscribe {
filter = true
}.doAfterSuccess {
System.out.println("NEW SINGLE!!!")
}.delay(4, TimeUnit.SECONDS).doAfterSuccess {
System.out.println("SINGLE!!!")
filter = true
}.toFlowable()
}.subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()).blockingFirst()
Run Code Online (Sandbox Code Playgroud)
但它似乎是一个hacky解决方案.我已经厌倦了onBackPressureDrop在interval功能之后应用,但它没有效果.
有什么建议?
是否可以过滤掉帖子中的短代码,然后运行短代码?
我的页面看起来像这样:
[summary img="images/latest.jpg"]
This here is the summary
[/summary]
Lots of text here...
Run Code Online (Sandbox Code Playgroud)
我只是想在特定页面上显示短代码.
尝试使用正则表达式,但它们似乎不起作用:
$the_query = new WP_Query('category_name=projects&showposts=1');
//loop
while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<b>';
the_title();
echo '</b>';
echo '<p>';
$string = get_the_content();
if (preg_match("[\\[[a-zA-Z]+\\][a-zA-Z ]*\\[\/[a-zA-Z]+\\]]", $string , $matches)) {
echo "Match was found <br />";
echo $matches[0];
}
echo '</p>';
endwhile;
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
编辑:
找到了临时解决方案.
while ( $the_query->have_posts() ) : $the_query->the_post();
$content = str_replace(strip_shortcodes(get_the_content()),"",get_the_content());
echo do_shortcode($content);
endwhile;
Run Code Online (Sandbox Code Playgroud)
我看到wordpress有一个用于条带化短代码但不用于条带内容的功能.所以我从整个帖子中删除了剥离的内容字符串以获得短代码.关于这一点的唯一不好的是,短代码必须在帖子的开头.
工具栏ActionMode似乎忽略了我在lollipop之前的设备上的风格.
这是我的风格:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:textColorPrimary">#DD000000</item>
<item name="android:textColorSecondary">#8A000000</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/secondary</item>
<item name="colorAccent">@color/accent</item>
<item name="android:actionModeStyle">@style/Widget.ActionMode</item>
<item name="android:actionModeBackground">@drawable/toolbar_action_background</item>
<item name="android:actionModeCloseDrawable">@drawable/ic_arrow_back_white_24dp</item>
</style>
<style name="Widget.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
<item name="android:background">@drawable/toolbar_action_background</item>
<item name="android:titleTextStyle">@style/TitleTextStyle</item>
</style>
<style name="TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#fff</item>
</style> …Run Code Online (Sandbox Code Playgroud) android ×4
c# ×2
silverlight ×2
django ×1
javascript ×1
jquery ×1
json ×1
kotlin ×1
php ×1
python ×1
rx-android ×1
rx-java ×1
rx-java2 ×1
rx-kotlin2 ×1
wagtail ×1
wordpress ×1