目标
没有从服务器下载图像时显示默认图像.
问题
我有一个带有图像视图的列表视图(以及一些文本框,但这并不重要).我的imageview为学生下载图像,但是当学生没有图像时,我试图显示默认图像.我尝试了两件我认为应该工作的东西,设置了一个默认图像,或者下面的代码.此代码取自活动文件,我将数据库列中的值写入变量(仅显示img以保持简单性)
//Image path returned
if (javaRealObject.getString("img").equals(""))
{
imgv = (ImageView)findViewById(R.id.ivImage);
imgv.setImageResource(R.drawable.emptyhead);
Log.d("Test", "Empty");
}
else//No image found in column
{
student.setImage(javaRealObject.getString("img"));
Log.d("Test","Not Empty");
}
Run Code Online (Sandbox Code Playgroud)
但是我得到了一个空参考imgv = (ImageView)findViewById(R.id.ivImage);,我不知道为什么我的图像视图被声明.如果没有从列提供默认图像的任何帮助,我们将不胜感激.
对于更多上下文,上面的代码是一个调用listview.xml的活动,然后调用row.xml.有问题的imageview在row.xml文件中.
ROW.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/ivImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:src="@drawable/empty_head" /> //default image here
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/tvFirstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/primary"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
调用行的列表
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" …Run Code Online (Sandbox Code Playgroud) 我的C#MVC项目使用Crystal Reports.不知何故,我的报告已停止工作并显示空白页面.当我检查网站时,我看到了错误
我已经验证了aspnet_client,但在那个目录下我有一个名为4_0_30319而不是的文件夹4_6_1055.当我编辑链接以使用该文件夹编号时,我再次能够浏览到css文件.
我的配置在哪里可以更改此号码4_0_30319?或者,重命名文件夹以匹配此数字是否更好?
情况
我正在开发一个应用程序,我可以在其中创建一个包含 X 个项目的网格,并且每个项目都有一个打印按钮。单击此打印按钮可以调用 ajax 函数,该函数将网格项的 ID 传递给控制器。我根据该 ID 检索相关数据,然后将其下载到 excel 文件中。(具体项目的检索尚未完成)
到目前为止我所拥有的
到目前为止,我已经有了下载 excel 文件的基本代码,以及我的 grid 。
问题
我面临的问题是,如果我单击“打印”按钮……什么也没有发生,即使我的exporttoexcel 函数中有一个断点,也会向我显示该函数已输入,我可以单步执行,尽管没有错误,但什么也没发生。但是,我添加了调用相同函数的随机按钮,当我单击该按钮时,下载了 excel 文件。因此,我认为这个问题与 aJax 有关。
代码
<input type="button" value="Test" onclick="location.href='@Url.Action("ExportToExcel", "Profile")'" />
Run Code Online (Sandbox Code Playgroud)
这是下载文件的代码。这是我添加的一个简单按钮。
function ExportToExcel(id) {
$.ajax({
type: "POST",
url: "@Url.Action("ExportToExcel", "Profile")",
data: { "id": id },
dataType: "json"
});
}
Run Code Online (Sandbox Code Playgroud)
这是我想要工作的功能,但它不起作用,我看不出我有什么问题。
导出到 Excel 代码
public void ExportToExcelx()
{
var products = new System.Data.DataTable("teste");
products.Columns.Add("col1", typeof(int));
products.Columns.Add("col2", typeof(string));
products.Rows.Add(1, "product 1");
products.Rows.Add(2, "product 2");
products.Rows.Add(3, "product 3");
products.Rows.Add(4, "product …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android应用程序,将listview更改为回收站视图.
问题
使用示例项目,我在适配器视图中处理对recylcer的单击.但是,从这个适配器,我有一个非常有时间调用一个新的片段.
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// android.app.FragmentManager fragmentManager = getFragmentManager();
// FragmentManager fragmentManager = ((Activity) context).getFragmentManager();
// FragmentManager manager = this.getSupportFragmentManager();
// FragmentManager manager= getContext().getFragmentManager();
// FragmentManager fragmentManager = newsAdapter().getActivity().getFragmentManager();
// getActivity().getFragmentManager();
Log.i("RecyclerViewItemClic", String.valueOf(getLayoutPosition()));
Log.i("RecyclerViewItemClic", personName.getText().toString());
String idnum = String.valueOf(personName.getText());
Log.i("RecyclerViewItemClic", idnum);
Log.i("RecyclerViewItemClic", personAge.getText().toString());
if (personName.getText().toString() .equals("1")) {
/*
fragmentManager.beginTransaction()
.replace(R.id.content_frame
,new numNumbersFrag())
.commit();
*/
((FragmentActivity) context).getFragmentManager().beginTransaction()
.replace(R.id.content_frame, new numNumbersFrag())
.commit();
}
}
Run Code Online (Sandbox Code Playgroud)
以上是我尝试导致错误的代码
尝试在空对象上调用虚拟方法'android.app.FragmentManager android.support.v4.app.FragmentActivity.getFragmentManager()'
如果我尝试使用getSupportFragmentManager(),或者导入片段而不是版本4,我也会得到相同的错误.
任何帮助,将不胜感激.
谢谢
我从 git 中提取了一个 nextJS 应用程序,并尝试使用npm run dev,启动它npx next dev npm run start,事实上,我运行的每个命令都给了我同样的错误。
为了进一步排除故障,我遵循了 YouTube 教程,并开始运行一个全新的项目npx create-next-app appname。同样的错误。
H:\Documents\Projects\React\NextTutorial\ninjalist>npm run dev ninjalist@0.1.0 dev next dev ready - started server on 0.0.0.0:3000, url: http://localhost:3000 error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error Error: Not supported at Object.loadConfig [as default] (H:\Documents\Projects\React\NextTutorial\ninjalist\node_modules\next\dist\server\config.js:399:74) at async NextServer.loadConfig (H:\Documents\Projects\React\NextTutorial\ninjalist\node_modules\next\dist\server\next.js:110:22) at async NextServer.prepare (H:\Documents\Projects\React\NextTutorial\ninjalist\node_modules\next\dist\server\next.js:92:24) at async H:\Documents\Projects\React\NextTutorial\ninjalist\node_modules\next\dist\cli\next-dev.js:126:9
最突出的是它无法加载,next.config.js
并且该文件的内容很简单
/** @type {import('next').NextConfig} */ module.exports = { reactStrictMode: true, …
我正在使用新的 amcharts5,尽管引用了我的旧代码和其他链接,但我似乎无法将饼图“切片”和标签更改为纯数字。
基本上我的代码和图表加载,但问题是我的值是用百分比而不是数字来描述的。这是我下面的代码,我试图解决这个问题。
任何帮助将不胜感激。
// Set data
series.data.setAll([
{ value: Type[0], category: "Type 1" },
{ value: Type[1], category: "Type 2" },
{ value: Type[2], category: "Type 3" },
]);
// Create legend
var legend = chart.children.push(am5.Legend.new(root, {
centerX: am5.percent(50),
x: am5.percent(50),
marginTop: 15,
marginBottom: 15
}));
legend.labels.template.text = "{category}: {value.value}";
legend.slices.template.tooltipText = "{category}: {value.value}";
chart.legend.valueLabels.template.text = "{value.value}";
legend.data.setAll(series.dataItems);
Run Code Online (Sandbox Code Playgroud)
问候