小编use*_*401的帖子

Python - Linux中的PYTHONPATH

我是新手,我已经开始学习python,但我有一些我无法理解的问题,

  1. 究竟什么是PYTHONPATH(在ubuntu中)?是一个文件夹?
  2. 默认情况下是在ubuntu中提供python还是必须显式安装?
  3. 所有模块所在的文件夹在哪里(我有很多名为python_的文件夹)?
  4. 如果我希望在编程时使用新模块(例如pyopengl),我应该在哪里介绍我在下载的文件夹中获得的所有文件夹?
  5. 从PYTHONPATH问题回来,如何配置PYTHONPATH以开始处理我的新模块?谢谢.

python

48
推荐指数
2
解决办法
23万
查看次数

在toArray(new String [0])中使用new String [0]有什么用;

嗨我有这样的事情:

saved = getSharedPreferences("searches", MODE_PRIVATE);
String[] mystring = saved.getAll().keySet().toArray(new String[0]);
Run Code Online (Sandbox Code Playgroud)

为什么我们需要new String[0]内部的论证toArray

java android

12
推荐指数
3
解决办法
2万
查看次数

android - 什么是视图层次结构?

我正在学习android,当然我是新手,我总是阅读类似于视图层次结构的东西,那究竟是什么意思呢?什么是视图层次结构?例如

//片段包含的框架不存在.片段//可能仍然是从其保存状态创建的,但是//没有理由尝试创建其视图层次结构,因为它//将不会显示.注意这不是必需的 - 我们可以//只运行下面的代码,我们将创建并返回//视图层次结构; 它永远不会被使用.

http://developer.android.com/reference/android/app/Fragment.html

android

8
推荐指数
2
解决办法
5095
查看次数

Android - AttributeSet

我有一个像这样的代码:

public class CannonView extends SurfaceViewimplements SurfaceHolder.Callback{
Activity activity;
Run Code Online (Sandbox Code Playgroud)

它的构造函数:

public CannonView(Context context, AttributeSet attrs){
Super(context,attrs)
activity = (Activity) context; 
Run Code Online (Sandbox Code Playgroud)

但显然AttributeSet什么也没做,我不知道为什么会这样,所以我的问题是:1.什么是AttributeSet?2.为什么我们需要提供AttributeSet attrs作为第二个参数?顺便说一下,其余代码用于使用画布进行绘画.谢谢.

android

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

android将图像保存到内部存储

我在实现此代码遇到问题在Android中保存和读取内部存储器中的位图/图像

保存和检索我想要的图像,这是我的代码:

ContextWrapper cw = new ContextWrapper(getApplicationContext());
             // path to /data/data/yourapp/app_data/imageDir
            File directory = cw.getDir("imageDir", Context.MODE_PRIVATE);
            // Create imageDir
            File mypath=new File(directory, + name + "profile.jpg");

            FileOutputStream fos = null;
            try {           

                fos = new FileOutputStream(mypath);

           // Use the compress method on the BitMap object to write image to the OutputStream
                myBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
                fos.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
Run Code Online (Sandbox Code Playgroud)

并检索(我不知道我做错了)

 @Override
   protected void onResume()
   {
      super.onResume();

      try {
          File f  = new File("imageDir/" + …
Run Code Online (Sandbox Code Playgroud)

android

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

Android - AsyncTask类和Execute方法

我有使用AsyncTask类的代码,用于使用数据库中的多个联系人填充listView.

@Override
   protected void onResume() 
   {
      super.onResume();

       new MyTask().execute((Object[]) null);
    } // end method onResume
Run Code Online (Sandbox Code Playgroud)

1.-为什么我通过这个:(Object[]) null)作为一个论点?

请参阅AsyncTask代码:

private class MyTask extends AsyncTask<Object, Object, Cursor> 
   {
      //used for database conection purpose 
      ConectToDatabase databaseConnector = 
         new ConectToDatabase(ThisClass.this);


      @Override
      protected Cursor doInBackground(Object... params)
      {
         databaseConnector.open();

         return databaseConnector.getMyContacts(); 
      } 

      // use the Cursor returned from the doInBackground method
      @Override
      protected void onPostExecute(Cursor result)
      {
         //My cursorAdadper defined in early code
         contactAdapter.changeCursor(result);
         databaseConnector.close();
      } 
   } 
Run Code Online (Sandbox Code Playgroud)

另一个AsyncTask问题:

delete.execute(new Long[] { rowID });
Run Code Online (Sandbox Code Playgroud)

2.-为什么我传递这个: …

android

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

android get json数组嵌套在数组中

这个问题

如何保存变量?

但是使用这个json代码:

{
    "restarutant": [
        {
            "name": "Hotel Raja",
            "photo": "http:\/\/i.imgur.com\/Mzt4u.jpg",
            "address": "93, 2ndc ross, GDP etx.",
            "area": "Vylaikaval",
            "city": "Bangalore",
            "rating": "4",
            "cuisines": {
                "first": "Chinese",
                "second": "Korean"
            }
        },
        {
            "name": "Hotel Raja2",
            "photo": "http:\/\/i.imgur2.com\/Mzt4u.jpg",
            "address": "93, 2ndc ross, GDP etx. number2",
            "area": "Vylaikaval2",
            "city": "Bangalore2",
            "rating": "4",
            "cuisines": {
                "first": "Chinese2",
                "second": "Korean2"
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

码:

JSONObject json = new JSONObject(thepreviousjson);
JSONArray jArray = json.getJSONArray("restaurant");

String name[] = new String[jArray.length()];
String photo[] = …
Run Code Online (Sandbox Code Playgroud)

android json

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

android从活动传递和检索额外的片段

我有一个活动,用户按下按钮然后发送到片段,但我希望传递一个额外的片段使用:

活动A(按钮在哪里):

public OnClickListener publish = new OnClickListener(){

       @Override
       public void onClick(View v) {


           Intent intent = new Intent(v.getContext(),ActivityB.class);
           intent.putExtra("friendIdRowID", rowID);
           startActivity(intent);


       }
   };
Run Code Online (Sandbox Code Playgroud)

活动B正在加载片段(我希望在其中检索额外的"friendIdRowID"),片段:

 @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.activity_main2, container, false);

            Bundle extras = getActivity().getIntent().getExtras();

        if (extras != null)
        {

            String myString = extras.getString("friendIdRowID");
}
        }
Run Code Online (Sandbox Code Playgroud)

但它无法正常工作,我可以做些什么来传递和检索额外的?谢谢.

android

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

省略用于打开标签的单词php

我的意思是:

<?php echo "hello"; ?>
Run Code Online (Sandbox Code Playgroud)

反对:

<? echo "hello"; ?>
Run Code Online (Sandbox Code Playgroud)

(没有php).

它工作正常,但有任何后果/糟糕的编程实践?没有问题??一切都顺利吗?怎么会发生什么?

php

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

Dart - 运行项目不会加载dart文件而不会在控制台中打印

我在dart中创建了一个新项目,并添加了一些代码,但是当我运行时(如果我使用"Run in Dartium"或者Ctrl + R运行dart文件并不重要)dart文件没有显示按钮我在main中创建,也在main()方法中创建了我添加了print()以便在控制台中打印消息,但没有显示任何内容.

另外:如果我使用"Run as JavaScript"运行按钮正常显示,这就是我正在做的事情:

在此输入图像描述

1.-我的HTML代码:

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Capitulo9</title>
    <link rel="stylesheet" href="capitulo9.css">
  </head>
  <body>


    <script type="application/dart" src="capitulo9.dart"></script>
    <script src="packages/browser/dart.js"></script>
    capitulo9.dart

  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

2.-我的dart文件(忘记上面的所有代码都被注释)我想打印消息并创建按钮:

main() {

  print("I wish to print this in the console");

  var startButton = new Element.html("<button>Start</button>");
    document.body.children.add(startButton);
}
Run Code Online (Sandbox Code Playgroud)

3.-我用"Run in Dartium"运行它,并带有绿色图标4.-
这就是我得到的,没有按钮5.-
没有打印信息6.-
也没有打印信息

我怎么能想用飞镖跑?谢谢

dart dartium

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

android Environment.getExternalStorageDirectory().getPath()

我有这个代码:

try {
            URL url = new URL (strURL);
            input = url.openStream();
            byte[] buffer = new byte[1500];
            OutputStream output = new FileOutputStream ("/sdcard/"+pos+".png");
Run Code Online (Sandbox Code Playgroud)

我得到这个错误:不要硬编码/ SD卡/使用environment.getexternalstoragedirectory().getpath()而不是

 OutputStream output = new FileOutputStream ("/sdcard/"+pos+".png");
Run Code Online (Sandbox Code Playgroud)

我已经读过:Android 4.2 - Environment.getExternalStorageDirectory().getPath()行为

所以问题是当我更换它时最终代码是什么?

android

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

标签 统计

android ×8

dart ×1

dartium ×1

java ×1

json ×1

php ×1

python ×1