小编Chi*_*lie的帖子

使用PhantomJS将JQuery注入Amazon.com页面会导致JQuery出现问题

我打开Amazon.com域中的任何页面(例如"http://www.amazon.com"),然后尝试像这样注入JQuery:

var injected = page.injectJs('jquery-1.7.1.js');
console.log("jquery was injected successfully: " + injected);
Run Code Online (Sandbox Code Playgroud)

此代码将打印true到控制台.但是,尝试$(document)从内部访问page.evaluate()如下:

page.onLoadFinished = function (status) {
    var results = page.evaluate(function() {
        $(document);    
    });

phantom.exit();
};
Run Code Online (Sandbox Code Playgroud)

将打印TypeError: 'undefined' is not a function到控制台.

此代码适用于我尝试过的大多数其他域.我注意到亚马逊似乎有自己的JQuery版本加载,我想知道它是否可能与我正在以某种方式加载的JQuery版本冲突.有任何想法吗?

jquery phantomjs

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

创建BroadcastReceiver,在安装/卸载任何应用程序时显示应用程序名称和版本号?

创建BroadcastReceiver,在安装/卸载任何应用程序时显示应用程序名称和版本号.但我得到包名intent.getData().但是当我试图使用packagemanager找到该应用程序的名称时,它会在所有安装/卸载/替换的情况下抛出异常.可能存在的问题是什么?如何解决这个问题?

码:

    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.content.pm.ApplicationInfo;
    import android.content.pm.PackageManager;
    import android.widget.Toast;

public class ApplicationStatusNotification extends BroadcastReceiver {

    /**
     * This method receives message for any application status(Install/ Uninstall) and display details.
     */
    @Override
    public void onReceive(Context context, Intent intent) {

        // Get application status(Install/ Uninstall)
        boolean applicationStatus = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
        String toastMessage = null;

        // Check if the application is install or uninstall and display the message accordingly
        if(intent.getAction().equals("android.intent.action.PACKAGE_INSTALL")){
            // Application Install
            toastMessage = "PACKAGE_INSTALL: …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver

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

ContextMenu title - >来自clicked listView项

根据尝试到ListView点击项目来设置文本菜单标题.ListView包含书签列表 - > FAVICON + BOOKMARK TITLE

@Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
      super.onCreateContextMenu(menu, v, menuInfo);
      menu.add(0, EDIT_ID, 0, R.string.menu_edit);
      menu.add(0, DELETE_ID, 0, R.string.menu_delete);
      menu.add(0, SHARE_ID, 0, R.string.menu_share);

      AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
      View itemID = (info.targetView);
      menu.setHeaderTitle("bla" + itemID);
    }
Run Code Online (Sandbox Code Playgroud)

当我运行这段代码就说明android.widget.RelativeLayout@423d2389或什么,如果我改变itemIDString itemID = ((TextView) info.targetView).getText().toString();我得到强制关闭的,即使在Eclipse中显示没有错误或当我运行该应用程序长按.

我也希望以同样的方式获得favicon ...

感谢帮助!

android

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

android setOnClickListener给出空指针异常?

我已经为onClick另一个视图的自定义对话框顶部编写了代码.它给了我nullpointer exception.我也尝试过使用Layout inflater.它给了我错误ok.setOnclickListener.我的代码有什么问题?

 ImageButton search =(ImageButton) findViewById(R.id.search);
            search.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {

                    Dialog searchDialog = new Dialog(Page.this);

                    /*LayoutInflater inflater = (LayoutInflater) getApplicationContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);


                     View layout = inflater.inflate(R.layout.search, null);
                     searchDialog.addContentView(layout, new LayoutParams(
                                LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                     searchDialog.setContentView(layout);*/

                    searchDialog.setContentView(R.layout.search);
                    searchDialog.setTitle("Search Dialog");
                    searchDialog.setCancelable(true);

                    Button ok = (Button)findViewById(R.id.OkButton);
                    ok.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            String searchString = null;
                            EditText searchText = (EditText)findViewById(R.id.searchText);
                            if(searchText.getText()!=null){
                                searchString = searchText.getText().toString();
                            }
                            Log.i("TAG","Search word :"+searchString);

                        }
                    });

                    searchDialog.show(); …
Run Code Online (Sandbox Code Playgroud)

android dialog

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

当使用onTap()时,Android Google Map视图会返回错误 - 应该显示Alertdialog

我目前修改了"Google地图视图"代码(如下所示),但是当地图加载并且您点击地图上的项目时,它会返回错误.

我相信它与mContext的null值有关,但我不确定,如果有人能帮我解决这个问题,我真的很感激:

protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
Context mContext = null;
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
Run Code Online (Sandbox Code Playgroud)

我的地图类:

package testing.map;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;

public class Mapview extends MapActivity {
    /** Called when the activity is first created. */

protected boolean isRouteDisplayed(){
    return false;
}
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mapview);

        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        List<Overlay> mapOverlays = mapView.getOverlays(); …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-markers

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

如何在netbeans 7.1.1中安装jstl.jar和standard.jar以及如何解决taglib的uri

我刚开始使用Netbeans 7.1.1并且在使用时遇到了问题taglib,它说的uri cannot be resolved in web.xml也不是jar文件.

我该怎么办?

我还发现这个问题可以通过添加jstl.jarstandard.jstlWEB-INF文件来解决.但没有改善.

那么有人可以建议如何解决这个URI问题?

java jar netbeans-7

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

Android Canvas到Bitmap

我一直在网上搜索如何将画布上的内容转换为位图.我尝试了多种方法来实现这一点,例如将绘图缓存保存到位图,但最终结果是背景位图闪烁了一会儿,然后变成了黑屏.测试图像显示在背景上,但不会被下次调用的背景覆盖OnDraw.

MainThreading{

                        ...

              if(notuptodate == true){

                        //call readyBackground to create the background bitmap
                        this.mainPanel.readyBackground(canvas);
                        //post the canvas
                        surfaceHolder.unlockCanvasAndPost(canvas);
                        //clean the Canvas
                        canvas = null;
                        //ready new Canvas
                        canvas = this.surfaceHolder.lockCanvas();//lock the canvas to enable editing






                    }//if not true

                    if (MainThreading.notuptodate == false){

                        mainPanel.onDraw(canvas);


                    }//if false
...
                 }//mainthreading

    //this method is run first to create the Bitmap that on draw will use
    public void readyBackGround(Canvas canvas){


        if (MainThreading.notuptodate){
            //method used to draw multiple Bitmaps onto the canvas
            renderBackground(canvas);

            //private …
Run Code Online (Sandbox Code Playgroud)

android bitmap android-canvas

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

Java 6文件输入输出流(相同文件)

我搜索并查看了这样的多个问题,但我的问题与我发现的任何问题都有所不同.我看过Java Docs.

如何打开此c文件的等价物:

stream1 = fopen (out_file, "r+b");
Run Code Online (Sandbox Code Playgroud)

一旦我从文件中完成了部分读取,无论文件中有多少字节,第一次写入都会使下一次读取返回EOF.

基本上我想要一个不这样做的文件I/O流.我正在尝试做的全部目的是替换当前文件中现有文件中的字节.在进行Read-> Write之前,我不想在副本中复制或复制.

java io file stream java-6

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

Facebook Graph API获取相册封面

我正在尝试使用以下内容获取专辑封面照片:

$facebook->api("/{ALBUM_ID}/picture", "get");
Run Code Online (Sandbox Code Playgroud)

但是,如果我使用上面的代码,我什么也得不回,如果我尝试在Facebook上使用Open Graph API资源管理器,它只是在那里加载图形.

如果我从浏览器访问它,我会得到一个返回图像.

以上调用是否不返回图片网址?如果没有,它返回什么以及如何使用它?

php facebook facebook-graph-api

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

Heroku(Python)Facebook应用程序"不正确的填充"错误

我正在关注Heroku-Facebook App教程,并在尝试在Facebook上查看我的应用时出错.与默认的应用程序主页相反,屏幕上会显示以下错误和回溯.

TypeError
TypeError: Incorrect padding

Traceback (most recent call last)

File "/app/lib/python2.7/site-packages/flask/app.py", line 1306, in __call__
return self.wsgi_app(environ, start_response)

File "/app/lib/python2.7/site-packages/flask/app.py", line 1294, in wsgi_app
response = self.make_response(self.handle_exception(e))

File "/app/lib/python2.7/site-packages/flask/app.py", line 1292, in wsgi_app
response = self.full_dispatch_request()

File "/app/lib/python2.7/site-packages/flask/app.py", line 1062, in full_dispatch_request
rv = self.handle_user_exception(e)

File "/app/lib/python2.7/site-packages/flask/app.py", line 1060, in full_dispatch_request
rv = self.dispatch_request()

File "/app/lib/python2.7/site-packages/flask/app.py", line 1047, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)

File "/app/exampleap
Run Code Online (Sandbox Code Playgroud)

修复此错误需要采取哪些具体步骤?

python facebook heroku

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