package com.example.user.likebutton;
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
List<Customer> customerList = new ArrayList<>();
List<Service> serviceList = new ArrayList<>();
List<Product> productList = new ArrayList<>();
List result = returnFunc();
printList(result);
}
public static void printList(List genericList) throws ClassNotFoundException, InstantiationException, IllegalAccessException{
Object obj=null;
String type = "";
Class c1 = null;
// identify the type of list
if(genericList.get(0) instanceof Customer){
c1 = Class.forName("Customer");
}else if(genericList.get(0) instanceof Service){
c1 = Class.forName("Service");
}else if(genericList.get(0) instanceof Product){
c1 = Class.forName("Product");
}else{
System.out.println("Error");
}
// create the list object
Object instance = c1.newInstance();
// iterate over the list and print the values
for(Object o : genericList){
System.out.println(o.toString());
}
}
//to randomly output a list
public static List returnFunc(){
ArrayList<List> tmp = new ArrayList<>();
ArrayList<Object> list_customer = new ArrayList<>();
list_customer.add(new Customer());
ArrayList<Object> list_service = new ArrayList<>();
list_service.add(new Service());
ArrayList<Object> list_product = new ArrayList<>();
list_product.add(new Product());
tmp.add(list_customer);
tmp.add(list_service);
tmp.add(list_product);
Random r = new Random();
return tmp.get(r.nextInt(3));
}
我无法解析
的符号import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.facebook.FacebookSdk;
import com.facebook.widget.LikeView;
public class MainActivity extends Activity {
private static final String TAG = "FBLike";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// To initialize Facebook SDK in your app
FacebookSdk.sdkInitialize(this);
// Get LikeView button
LikeView likeView = (LikeView) findViewById(R.id.like_view);
// Set the object for which you want to get likes from your users (Photo, Link or even your FB Fan page)
likeView.setObjectId("https://www.facebook.com/tomatojuice");
// Set foreground color fpr Like count text
likeView.setForegroundColor(-256);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
LikeView.handleOnActivityResult(this, requestCode, resultCode, data);
Log.i(TAG, "OnActivityResult...");
}
}
我似乎无法导入此文件 import com.facebook.widget.LikeView;
介意告诉我任何我忘记添加的东西?我已经将存储库mavenCentral()置于存储库中并将facebook sdk编译为'com.facebook.android:facebook-android-sdk:4.6.0'以获取依赖