我在Android开发中绝对是新的,我发现使用BitmapFactory.decodeResource()方法进入实用程序类(不是活动类的类)的问题.
所以我正在对我的代码进行一些重构,我必须移动这个代码行:
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.chef_hat_ok);
Run Code Online (Sandbox Code Playgroud)
从活动类方法到我在实用程序类中声明的方法.
它在活动类中运行良好,但将int移入实用程序类方法,如下所示:
public class ImgUtility {
public Bitmap createRankingImg(int difficulty) {
// Create a Bitmap image starting from the star.png into the "/res/drawable/" directory:
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.chef_hat_ok);
return myBitmap;
}
}
Run Code Online (Sandbox Code Playgroud)
我在getResources()方法上获取了一条IDE错误消息,IDE对我说:
无法解析方法'getResources()'
我认为这是因为getResources()方法检索与活动类相关的内容.
查看旧代码,我可以看到getResources()方法返回一个ContextThemeWrapper对象.我试图在AppCompatActivity类中搜索(因为我的原始活动扩展了它),但我找不到.
所以我的怀疑是:
1)主要问题是:如何在我的previus ImgUtility clas中正确使用BitmapFactory.decodeResource()方法?
2)为什么当我使用BitmapFactory.decodeResource()方法时,它将ContextThemeWrapper对象(由getResources()方法返回)作为参数?究竟什么代表了这个对象?它与活动类有什么关系?在哪里申报?
TNX
java android bitmapfactory android-activity android-resources
我不是这样的数据库,我在尝试对Microsoft SQL Server数据库中的表执行简单的插入查询时遇到以下问题.
因此,此表包含一个datetime名为TIMESTAMP必须包含当前日期和当前时间的列.
我试图以这种方式做但不能工作:
INSERT INTO TirAliquotaRamoI (DataElaborazione,
TassoLordoAnnuoAppl,
TassoGiornaliereNetto,
Aliquota,
DataInizio,
DataFine,
TIMESTAMP)
VALUES ('2015-08-01 00:00:00',
0,
0,
1,
'2015-08-01 00:00:00',
'2100-12-32',
TIMESTAMP);
Run Code Online (Sandbox Code Playgroud)
它给我以下错误消息:
16:49:10 [INSERT - 0行,0.000秒]
错误代码:207,SQL状态:S0001无效的列名称'TIMESTAMP'.
为什么?我错过了什么?怎么了?我该如何解决这个问题?
我在PostgreSQL中绝对是新手,我正在按照本教程检查我的PostgreSQL安装是否安装了PostGIS扩展.
这是教程:https://www.a2hosting.com/kb/developer-corner/postgresql/determining-the-postgresql-and-postgis-versions
我正在使用PostgreSQL 9.6.1.
所以我可以通过命令行访问我的PostgreSQL,并执行了以下命令:
SELECT PostGIS_full_version();
Run Code Online (Sandbox Code Playgroud)
这是获得的输出:
C:\ Users\Andrea> pasql -u admin'pasql'未被识别为内部或外部命令,可运行程序或批处理文件.
C:\Users\Andrea>psql -U postgres
psql (9.6.1)
ATTENZIONE: Il code page della console (850) differisce dal code page
di Windows (1252). I caratteri a 8-bit potrebbero non
funzionare correttamente. Vedi le pagine di riferimento
psql "Note per utenti Windows" per i dettagli.
Digita "help" per avere un aiuto.
postgres=# SELECT PostGIS_full_version();
ERROR: function postgis_full_version() does not …Run Code Online (Sandbox Code Playgroud) 我不是这样的Spring Data JPA(使用Hibernate 4.3.11.Final),我有以下情况.
我有这个SQL查询(直接执行MySql工作正常),查询只是找到注册到住宿表中的所有酒店,从选定的点到特定范围:
SET @fiumicino = GeomFromText('POINT(41.768835 12.247658)');
SELECT *
FROM accomodation a
WHERE earth_circle_distance(@fiumicino, a.geographical_position) < 7
Run Code Online (Sandbox Code Playgroud)
因此,您可以在previus代码中看到此查询有2个参数:
好的,它工作正常......
所以我试着将它转换为我的Spring Data JPA存储库接口的本机SQL查询,我做了:
@Repository
public interface AccomodationDAO extends JpaRepository<Accomodation, Long> {
@Query(value = "SELECT * FROM accomodation a WHERE earth_circle_distance(?0, a.geographical_position) < ?1", nativeQuery = true)
Accomodation findByRange(Point location, int range);
}
Run Code Online (Sandbox Code Playgroud)
基本上我用@ 0参数取代@fiumicino,用?1取代距离范围的7值. …
我不太喜欢 GIT,我有以下问题。
我的项目中有一些未提交的文件,我已经通过此声明隐藏了这些文件:
git stash
Run Code Online (Sandbox Code Playgroud)
然后我拉取了一个coolegue的工作的存储库,这似乎正确地覆盖了我的隐藏文件的更改。
现在我想在不丢失同事修改的情况下检索特定隐藏文件的内容。
我不想覆盖拉取的版本,而只想访问特定文件的隐藏版本的代码。
执行git stash list我获得:
$ git stash list
stash@{0}: WIP on master: fd2a59b First version of iterate/aggregate for data received from dataservice
stash@{1}: WIP on master: 4910263 DSS project added
Run Code Online (Sandbox Code Playgroud)
我怎样才能从外壳做到这一点?
CREATE TABLE MeteoForecast (
id BigInt(20) NOT NULL AUTO_INCREMENT,
localization_id BigInt(20) NOT NULL,
seasonal_forecast_id BigInt(20),
meteo_warning_id BigInt(20),
start_date DateTime NOT NULL,
end_date DateTime NOT NULL,
min_temp Float,
max_temp Float,
icon_link VarChar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
PRIMARY KEY (
id
)
) ENGINE=InnoDB;
Run Code Online (Sandbox Code Playgroud)
它包含一些这样的数据:
id localization_id start_date end_date min_temp max_temp icon_link
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 1 18/09/2017 06:00:00 18/09/2017 12:00:00 15 24 Mostly_Cloudy_Icon.png
2 1 18/09/2017 12:00:00 18/09/2017 18:00:00 15 24 Light_Rain.png
3 1 19/09/2017 06:00:00 19/09/2017 12:00:00 12 22 …Run Code Online (Sandbox Code Playgroud) 我不是那么进入数据库,我有以下疑问涉及我在MySql DB 上运行的查询.
我有这个问题:
SELECT
CD.id AS id,
CD.commodity_name_en AS commodity_name_en
FROM MarketDetails AS MD
INNER JOIN MarketDetails_CommodityDetails AS MD_CD
ON MD.id = MD_CD.market_details_id
INNER JOIN CommodityDetails AS CD
on MD_CD.commodity_details_id = CD.id
WHERE MD.localization_id = 1
Run Code Online (Sandbox Code Playgroud)
返回这样的东西(代表某些市场的商品清单):
id commodity_name_en
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 Rice-Asia
2 Apple banana
3 Avocado
4 Red onion
5 White onion
6 Green Beans
7 Bell pepper
8 Carrot
9 Tomatoes
10 Irish potatoes
11 Maize
1 Rice-Asia
3 Avocado
5 White onion
8 Carrot
11 …Run Code Online (Sandbox Code Playgroud) 我不是很喜欢C#(我来自Java)并且我对以下与此示例相关的委托方法的确切工作方式存在以下疑问:
List<string> urlList = IndirizziProtocolliSQL.GetListaIndirizziSiti(dbConfig);
foreach (string currentUrl in urlList)
{
Debug.Print("Current url: " + currentUrl);
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
using (SPSite oSiteCollection = new SPSite(currentUrl))
{
using (SPWeb oWebsite = oSiteCollection.OpenWeb())
{
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解阅读官方文档:https: //docs.microsoft.com/en-us/dotnet/csharp/programming-guide/delegates/
的委托()用于传递的方法作为另一种方法的输入参数.
例如,如果我有类似的东西:
public delegate int MyDelegate (string s);
Run Code Online (Sandbox Code Playgroud)
它表示对具有此方法签名的任何方法的引用(返回类型,方法名称,在put参数中).
如果它是正确的,究竟是什么意味着我的第一个原始例子?为什么我有一个使用(...){...}块的方法签名?
这种语法的确切含义是什么?
我不太喜欢SQL Server,我有以下疑问:我必须要求创建一个可以在某些数据库上工作的用户。该用户必须创建\删除表,在这些表中插入\删除记录。
在这些数据库上必须为该用户设置什么类型的权限?是的dbowner执行这些操作好吗?(尤其是该用户可以创建\删除表非常重要)还是我遗漏了什么?
我不太喜欢GIT,并且遇到以下问题:我在GitHub上创建了一个新存储库。然后,在我的项目文件夹中,我执行了以下命令:
1)我将 init 存储库设置到我的项目文件夹中:
git init
Run Code Online (Sandbox Code Playgroud)
2) 我设置了对我的 GitHub 存储库的引用:
git remote add origin https://github.com/AndreaNobili/SpringBoot-Excel-API.git
Run Code Online (Sandbox Code Playgroud)
并检索参考信息我得到这个:
developer@developer-virtual-machine:~/git/SOC-dashboard$ git remote -v
origin https://github.com/AndreaNobili/SpringBoot-Excel-API.git (fetch)
origin https://github.com/AndreaNobili/SpringBoot-Excel-API.git (push)
Run Code Online (Sandbox Code Playgroud)
所以看起来没问题。
3)首先我尝试推送我的项目代码:
developer@developer-virtual-machine:~/git/SOC-dashboard$ git push origin master
Username for 'https://github.com': nobili.andrea@gmail.com
Password for 'https://my.mail@gmail.com@github.com':
To https://github.com/AndreaNobili/SpringBoot-Excel-API.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/AndreaNobili/SpringBoot-Excel-API.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote …Run Code Online (Sandbox Code Playgroud)