小编Dip*_*iya的帖子

如何使用Twitter4j api在推文上回复?

我在twitter上工作,我有访问令牌,我现在也收到推文我想在Twitter网站上回复那些推文,因为我使用下面的代码,但它不是回复推文但它更新我的状态请帮我解决这个问题谢谢..

public void tweetReply() {
    try {
        // System.out.println("Post Id= " + itemsObj.postId);
        AccessToken a = new AccessToken(twittertokens[0], twittertokens[1]);
        Twitter twitter = new TwitterFactory().getInstance();

        twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
        twitter.setOAuthAccessToken(a);
        Long id = new Long("236178766597087234");
        twitter.updateStatus(new StatusUpdate("@lalitrajput024  this is to test For reply option ").inReplyToStatusId(id));

    } catch (Exception e) {
        // TODO: handle exception
    }
}
Run Code Online (Sandbox Code Playgroud)

android twitter4j

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

Android - 自定义ArrayAdapter类中的notifyDataSetChange

我有一个名为InteractiveArrayAdapter的自定义ArrayAdapter,它为列表视图中的每个项添加按钮和按钮侦听器.在适配器内部有一个getView方法,可以创建一个视图充气器.在这里是创建我的按钮并创建buttonListener的地方.单击该按钮时,我删除与该按钮关联的ArrayList中的元素.问题是我无法弄清楚如何从这个OnClick方法中调用notifyDataSetChange,或者通知适配器需要更新listView的另一种方法.

定制适配器:

public class InteractiveArrayAdapter extends ArrayAdapter<String> {

  private final List<String> list;
  private final Activity context;
  private ListView listV;

  public InteractiveArrayAdapter(Activity context, List<String> list) {
    super(context, R.layout.rowbuttonlayout, list);
    this.context = context;
    this.list = list;

  }

  static class ViewHolder {
    protected TextView text;
    protected Button button;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = null;

    if (convertView == null) {
      LayoutInflater inflator = context.getLayoutInflater();
      view = inflator.inflate(R.layout.rowbuttonlayout, null);
      final ViewHolder viewHolder = new ViewHolder();
      viewHolder.text …
Run Code Online (Sandbox Code Playgroud)

android android-arrayadapter

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

如何在Edittext中添加笑脸/表情符号?

如何在Edittext中添加笑脸/表情符号?

任何源代码都可在Internet上获得,如果是,请给我链接.

提前致谢.

android

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

如何在Android中获得距离公里?

我是谷歌地图的新手,我想计算android中两个地方之间的距离.

为此,我得到两个位置lat和lag位置,我写下面的代码:

private double getDistance(double lat1, double lat2, double lon1, double lon2) {
    double dLat = Math.toRadians(lat2 - lat1);
    double dLon = Math.toRadians(lon2 - lon1);
    double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
    double temp = 6371 * c;
    temp=temp*0.621;
    return temp;
}
Run Code Online (Sandbox Code Playgroud)

上面的代码无法给出两个地方之间的准确距离.找到距离的另一种方法是什么,请给我任何建议.

android distance google-places-api

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

Android:获取设备应用程序列表 - 非常慢

我需要在用户打开我的应用后5-10秒内获取设备上安装的所有应用的列表.

这是因为,它需要大约.对于我的Android应用程序的典型用户,请求5-10秒,以请求有关设备上安装的应用程序的信息.

为了相关,我必须在每次加载应用程序时创建已安装应用程序列表的新副本.

但是,使用下面的代码在四核Android设备上花费超过30秒.400个应用程序(系统和已安装 - 我需要两个).

我在"创建时"执行了代码,但没有人会等待30秒才能打开应用程序.所以我把它移到AsyncTask,所以我的应用程序打开immediadetelly.但仍然需要+30秒; 如果在加载列表之前有人要求提供特定的应用程序,他们可能无法获得正确的信息.

为什么这段代码这么慢?我该怎么做才能加快速度呢?我会向任何可以提高10倍或者给我一个很好的小费的人支付金币.

final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo packageInfo : packages) {
    InstalledAppsName.add(packageInfo.loadLabel(pm).toString());
    CountApps=CountApps+1;
}
Run Code Online (Sandbox Code Playgroud)

android list

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

如何在ListView中添加多个标题视图

我有一个自定义适配器,我ListView想将项目名称添加为工作请求的标题.添加单个标头工作正常,但我不知道如何使用添加多个标头addHeaderView.我不明白到底要放在哪里setAdapter或者它应该多次放置?

这是我的单个标头的java代码,它有效:

mListView = (ListView)findViewById(R.id.dashboardList);
View header1 =  getLayoutInflater().inflate(R.layout.listview_header, null, false);
tv = (TextView) header1.findViewById(R.id.listHeader);
adapter = new MyCustomAdapter(MyDashboardActivity.this, R.layout.mydashboard_row, dashboardBean);
tv.setText("Project 1");
mListView.addHeaderView(header1, null, false);
for (int i=0; i < 7; i++) {
     dashboardBean.add(new DashboardBean(workRequests[i],status[i],actualHours[i]));
}
mListView.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

现在,我尝试了两个标题:

mListView = (ListView)findViewById(R.id.dashboardList);
View header1 =  getLayoutInflater().inflate(R.layout.listview_header, null, false);
tv = (TextView) header1.findViewById(R.id.listHeader);
adapter = new MyCustomAdapter(MyDashboardActivity.this, R.layout.mydashboard_row, dashboardBean);
tv.setText("RxOffice");
mListView.addHeaderView(header1, null, false);
for (int i=0; i < 4; i++) {
     dashboardBean.add(new DashboardBean(workRequests[i],status[i],actualHours[i])); 
}

tv.setText(Project …
Run Code Online (Sandbox Code Playgroud)

android android-listview

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

AnimationDrawable在Android 2.2中不起作用

我像这样使用AnimationDrawable:

ImageView rocketImage = (ImageView) layout.findViewById(R.id.animation);
rocketImage.setBackgroundResource(R.drawable.progress_blue_animation);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start();
Run Code Online (Sandbox Code Playgroud)

此代码适用于Android 3.0/4.0/4.1/4.0,但在Android 2.2中不起作用.如何解决这个问题呢?

android drawable android-animation

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

解析XML不匹配标记时出错

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/tab1"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:gravity="center"
                    android:text="About the course"
                    android:textColor="#0000ff"
                    android:textSize="20dp" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp"
                    android:text="This course equips you the skills to handle and manage the technology that is so vital in the field of media and communication, namely digital communication, wireless devices, broadband, media design and other emerging media and telecommunication technologies."
                    android:textColor="#0000ff"
                    android:textSize="14dp" />
                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="214dp"
                    android:layout_height="171dp"
                    android:layout_marginTop="10dp" …
Run Code Online (Sandbox Code Playgroud)

xml tags parsing android mismatch

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

android:layout_marginRight属性不适用于RelativeLayout

我有一个内部相对布局有2个图像,当我设置android:layout_marginRight属性时它没有做任何事情.

这是我的代码:

<RelativeLayout
    android:id="@+id/location_image_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="80dp" />

    <ImageView
        android:layout_width="69.33dp"
        android:layout_height="72dp"
        android:background="@drawable/icon"
        android:layout_centerInParent="true" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout

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

在Spinner上设置文本

这是AccountListView,它检索,我已经在数据库中添加列表视图显示数据,我添加了一些现金和银行账户,当我在名单上的现金点击查看打开事务的意图,其上有一个微调其中现金和银行已经加入,我希望它显示,我点击了列表视图中的数据.请注意,现金和银行显示的余额仅适用于微调器.

public class AccountListActivity extends Activity implements OnClickListener, OnItemClickListener {

private ListView AccountListView;
private Button addNewAccountButton;

private ListAdapter AccountListAdapter;


private ArrayList<AccountDetails> pojoArrayList;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list);

    AccountListView = (ListView) findViewById(R.id.AccountListView);
    AccountListView.setOnItemClickListener(this);
    registerForContextMenu(AccountListView);
    addNewAccountButton = (Button) findViewById(R.id.namesListViewAddButton);
    addNewAccountButton.setOnClickListener(this);

    pojoArrayList = new ArrayList<AccountDetails>();


    AccountListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, populateList());

    AccountListView.setAdapter(AccountListAdapter);

}
@Override  
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {  
super.onCreateContextMenu(menu, v, menuInfo);  
    menu.setHeaderTitle("Menu");  
    menu.add(0, v.getId(), 0, "Update");  
    menu.add(0, …
Run Code Online (Sandbox Code Playgroud)

android android-spinner

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