我从Firebase获取此警告消息,用于orderByChild我在JavaScript查询中使用的每一个:
FIREBASE警告:使用未指定的索引.考虑在/ tables中添加".indexOn":""到您的安全规则以获得更好的性能
到目前为止,我的查询运行速度非常快,所以我认为没有必要包括indexOn.只是想知道什么是负面影响?
另外,我如何实际禁用警告,因为在调试时它们非常烦人.
当我试图计算加速时,我陷入了困境。所以给出的问题是:
问题1
如果程序的 50% 增强了 2 倍,其余 50% 增强了 4 倍,那么增强带来的整体加速是多少?提示:假设增强前(未增强)机器中程序的执行时间为T,然后求增强后的总执行时间T'。加速比是T/T'。
我唯一知道的是加速比=增强前的执行时间/增强后的执行时间。那么我可以假设答案是:
加速比 = T/((50/100x1/2) + (50/100x1/4))
增强后的总执行时间 = T + 加速比
(50/100x1/2) 因为 50% 增强了 2 倍,4 倍也是如此。
问题2
让我们假设一下,通过处理器设计中的某种改进/增强,可以使程序 (2/3)rd 的执行速度无限快。那么与未增强的(原始)机器相比,增强的处理器运行速度会快多少倍?
我可以假设它比 100/(2/3) = 150 快 150 倍吗
有任何想法吗?提前致谢。
我想以编程方式将边距设置为View.这是我的XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/llAttendeeList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000">
<ListView
android:id="@+id/attendeelistview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#F6CECE" >
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当我的按钮onClick调出弹出窗口视图时的方法:
private void openPopUp() {
LayoutInflater layoutInflater = (LayoutInflater) getActivity()
.getBaseContext().getSystemService(
context.LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.event_attendee_pop,
null);
llAttendeeList = (LinearLayout) popupView
.findViewById(R.id.llAttendeeList);
attendeeListView = (ListView) popupView.findViewById(R.id.attendeelistview);
LayoutParams params = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
params.setMargins(10, 10, 10, 0);
popupView.setLayoutParams(params);
final PopupWindow popupWindow = new PopupWindow(popupView,
LayoutParams.WRAP_CONTENT, 350);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setTouchInterceptor(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) …Run Code Online (Sandbox Code Playgroud) 我在chart.js图例方面遇到了一些问题。具有长文本的图例占用太多空间,从而导致饼图的尺寸减小:
另一个例子是这样的:
如果我有更多的传说,那么甜甜圈图最终将变得越来越小。
我试图设置maxWidth但无济于事。
var options = {
layout: {
padding: {
top: 5
}
},
responsive: true,
maintainAspectRatio: false,
legend: {
display: true,
position: 'right',
maxWidth: 100,
onClick: null
},
animation: {
animateScale: true,
animateRotate: true
},
};
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我尝试按照此[解决方案] [3]创建html图例:
<div class="box-body" style="height:350px;">
<div class="float-left">
<div class="float-left" style="width:70%">
<canvas id="brandChart" style="position: relative; height: 350px;"></canvas>
</div>
<div class="float-left" style="width:30%">
<div id="js-legend" class="chart-legend">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
它确实限制了图例的宽度,但是这又导致了另一个问题,就是我折叠并扩展了div之后,画布丢失了,而我只剩下了图例div。
我在尝试使用 chart.js 为混合图表自定义悬停工具提示时遇到了一些问题。
我有一个显示特定产品总利润的条形图和一个显示特定产品总量的折线图。当我将鼠标悬停在条形图上时,我希望工具提示显示如下内容:
Total profit: $ 1399.30
Run Code Online (Sandbox Code Playgroud)
价格应以两位小数格式附加在“总利润:$”后面。当我将鼠标悬停在折线图上时,我想显示如下内容:
Quantity sold: 40 unit(s)
Run Code Online (Sandbox Code Playgroud)
这是我填充相关数组的代码:
for(var i = 0 ; i < topProductList.length; i++){
labelData.push(topProductList[i].itemName);
amountData.push((topProductList[i].price * topProductList[i].quantity).toFixed(2));
quantityData.push(topProductList[i].quantity);
}
Run Code Online (Sandbox Code Playgroud)
我尝试按照@GRUNT 的建议合并回 x 轴标签的回调:
tooltips: {
callbacks: {
title: function(t, d) {
return d.labels[t[0].index].replace(/\n/, ' ');
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的图表的选项:
var opt = {
type: "bar",
data: {
labels: labelData,
datasets: [{
type: "bar",
label: 'Total Profit ',
data: amountData,
},{
type: "line",
label: 'Quantity Sold ',
data: quantityData,
}]
}, …Run Code Online (Sandbox Code Playgroud) 我在为 chart.js 自定义图表图例时遇到了一些问题。这是我的圆环图的样子:
如您所见,侧面的图例未显示彩色方形图标。没错,它应该是这样的:
我的图表 HTML:
<canvas id="merchantChart" height="660" width="330"></canvas>
<div id="merchantLegend" class="chart-legend"></div>
Run Code Online (Sandbox Code Playgroud)
这是我为每个切片设置颜色并覆盖由 chart.js 提供的默认图表图例的部分:
var opt = {
type: "doughnut",
data: {
labels: labelData,
datasets: [{
data: priceData,
backgroundColor: "rgba(220,220,220,0)",
borderColor: colorArr,
borderWidth: 1.5,
hoverBackgroundColor: colorArr
}]
},
options: options
};
if (merchantChart) merchantChart.destroy();
merchantChart = new Chart(ctx, opt);
merchantChart.update();
merchantLegend.innerHTML = merchantChart.generateLegend();
Run Code Online (Sandbox Code Playgroud)
如您所见,因为我将每个切片的backgroundColor 设置为透明,有没有办法根据每个切片的borderColor 生成Legend()?
谢谢!
在尝试从webview转换为pdf时尝试在多页pdf文件中包含页眉和页脚时遇到了一些问题.以下是我如何构建要在webview中显示的内容:
public String toHtml() {
StringBuilder htmlStr = new StringBuilder("");
htmlStr.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html\"; charset=utf-8>");
htmlStr.append("<title>").append("").append("</title>");
htmlStr.append("</head>\n");
htmlStr.append("<body>").append("").append("</body>");
htmlStr.append("<footer>").append("").append("</footer>");
htmlStr.append("</html>");
return htmlStr.toString();
}
Run Code Online (Sandbox Code Playgroud)
我按照本指南从webview生成PDF.它确实设法生成PDF文件.但是,标题只出现在第一页,页脚只出现在PDF文件的最后一页.有关如何在PDF文件中的所有页面中包含页眉和页脚的任何想法?
谢谢!
在尝试从片段中获取值时,我遇到了一些问题。我的片段 A 将打开片段 B,当单击片段 B 中的按钮时,我想获取一个值并传回片段 A 以进行显示。但是,我不知道该怎么做。
片段A:
@Click(R.id.buttonAttach)
void buttonAttachClicked(View v){
SupportAttachFileFragment fragment = new SupportAttachFileFragment_();
fragment.show(getFragmentManager(), null);
// get value here and display
textViewLogCounter.setText();
}
}
Run Code Online (Sandbox Code Playgroud)
片段B:
当这个按钮 onClicked 时,我想将值传递回片段 A 并显示。
@Click(R.id.buttonAttach)
void buttonAttachClicked(View v){
System.out.println("TOTAL " + selectedRows.size());
dismiss();
}
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做。我在考虑 Bundle 但 Bundle 是将参数传递给新活动。在这种情况下,我的片段已经打开,但我想传回一些值。
有任何想法吗?谢谢!
我在Android Studio中遇到了一些问题.所以基本上这是我的MainActivity:
public class MainActivity extends FragmentActivity {
final Context context = this;
ViewPager Tab;
TabPagerAdapter TabAdapter;
ActionBar actionBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabAdapter = new TabPagerAdapter(getSupportFragmentManager());
Tab = (ViewPager) findViewById(R.id.pager);
Tab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar = getActionBar();
actionBar.setSelectedNavigationItem(position);
}
});
Tab.setAdapter(TabAdapter);
actionBar = getActionBar();
// Enable Tabs on Action Bar
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.TabListener tabListener = new ActionBar.TabListener() {
@Override
public void onTabReselected(android.app.ActionBar.Tab tab,
android.app.FragmentTransaction ft) {
}
@Override
public void onTabSelected(android.app.ActionBar.Tab …Run Code Online (Sandbox Code Playgroud) 尝试使用递归进行反向数组时遇到问题。这是函数原型:
void rReverseAr(int ar[ ], int size);
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
int main()
{
int ar[10], size, i;
printf("Enter array size: ");
scanf("%d", &size);
printf("Enter %d numbers: ", size);
for (i = 0; i<size; i++)
scanf("%d", &ar[i]);
rReverseAr(ar, size);
printf("rReverseAr(): ");
for (i = 0; i<size; i++)
printf("%d ", ar[i]);
return 0;
}
void rReverseAr(int ar[], int size) {
int start = 0, end = size - 1, temp;
if (start < end) {
temp = ar[start];
ar[start] = ar[end];
ar[end] = temp; …Run Code Online (Sandbox Code Playgroud)